javax.wsdl.Input Java Examples

The following examples show how to use javax.wsdl.Input. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
private Operation addOWOperation2PT( Definition def, PortType pt, OneWayOperationDeclaration op ) {
	Operation wsdlOp = def.createOperation();

	wsdlOp.setName( op.id() );
	wsdlOp.setStyle( OperationType.ONE_WAY );
	wsdlOp.setUndefined( false );

	Input in = def.createInput();
	Message msg_req = addRequestMessage( localDef, op );
	msg_req.setUndefined( false );
	in.setMessage( msg_req );
	wsdlOp.setInput( in );
	wsdlOp.setUndefined( false );

	pt.addOperation( wsdlOp );

	return wsdlOp;
}
 
Example #2
Source File: OperationInfo.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
public OperationInfo(Operation operation) {
    targetMethodName = operation.getName();

    Input inDef = operation.getInput();
    if (inDef != null) {
        Message inMsg = inDef.getMessage();
        if (inMsg != null) {
            input = getParameterFromMessage(inMsg);
        }
    }
    Output outDef = operation.getOutput();
    if (outDef != null) {
        Message outMsg = outDef.getMessage();
        if (outMsg != null) {
            output = getParameterFromMessage(outMsg);
        }
    }
    for (Fault fault : (Collection<Fault>) operation.getFaults().values()) {
        Message faultMsg = fault.getMessage();
        if (faultMsg != null) {
            faults.add(getParameterFromMessage(faultMsg));
        }
    }
}
 
Example #3
Source File: WSDL11SOAPOperationExtractor.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the target namespace given the soap binding operation
 *
 * @param bindingOperation soap operation
 * @return target name space
 */
private String getTargetNamespace(BindingOperation bindingOperation) {

    Operation operation = bindingOperation.getOperation();
    if (operation != null) {
        Input input = operation.getInput();

        if (input != null) {
            Message message = input.getMessage();
            if (message != null) {
                Map partMap = message.getParts();

                for (Object obj : partMap.entrySet()) {
                    Map.Entry entry = (Map.Entry) obj;
                    Part part = (Part) entry.getValue();
                    if (part != null) {
                        if (part.getElementName() != null) {
                            return part.getElementName().getNamespaceURI();
                        }
                    }
                }
            }
        }
    }
    return targetNamespace;
}
 
Example #4
Source File: ServiceWSDLBuilderTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testGreetMeOneWayOperation() throws Exception {
    setupWSDL(WSDL_PATH);
    PortType portType = newDef.getPortType(new QName(newDef.getTargetNamespace(),
        "Greeter"));
    Operation greetMeOneWay = portType.getOperation("greetMeOneWay", "greetMeOneWayRequest", null);
    assertNotNull(greetMeOneWay);
    assertEquals("greetMeOneWay", greetMeOneWay.getName());
    Input input = greetMeOneWay.getInput();
    assertNotNull(input);
    assertEquals("greetMeOneWayRequest", input.getName());
    Message message = input.getMessage();
    assertNotNull(message);
    assertEquals("greetMeOneWayRequest", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("in", message.getPart("in").getName());
    Output output = greetMeOneWay.getOutput();
    assertNull(output);
    assertEquals(0, greetMeOneWay.getFaults().size());
}
 
Example #5
Source File: AttributeVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private Operation generateOperation(String name, Message inputMsg, Message outputMsg) {
    Input input = definition.createInput();
    input.setName(inputMsg.getQName().getLocalPart());
    input.setMessage(inputMsg);

    Output output = definition.createOutput();
    output.setName(outputMsg.getQName().getLocalPart());
    output.setMessage(outputMsg);

    Operation result = definition.createOperation();
    result.setName(name);
    result.setInput(input);
    result.setOutput(output);
    result.setUndefined(false);

    portType.addOperation(result);

    return result;
}
 
Example #6
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Operation addRROperation2PT( Definition def, PortType pt, RequestResponseOperationDeclaration op ) {
	Operation wsdlOp = def.createOperation();

	wsdlOp.setName( op.id() );
	wsdlOp.setStyle( OperationType.REQUEST_RESPONSE );
	wsdlOp.setUndefined( false );

	// creating input
	Input in = def.createInput();
	Message msg_req = addRequestMessage( localDef, op );
	in.setMessage( msg_req );
	wsdlOp.setInput( in );

	// creating output
	Output out = def.createOutput();
	Message msg_resp = addResponseMessage( localDef, op );
	out.setMessage( msg_resp );
	wsdlOp.setOutput( out );

	// creating faults
	for( Entry< String, TypeDefinition > curFault : op.faults().entrySet() ) {
		Fault fault = localDef.createFault();
		fault.setName( curFault.getKey() );
		Message flt_msg = addFaultMessage( localDef, curFault.getValue() );
		fault.setMessage( flt_msg );
		wsdlOp.addFault( fault );

	}
	pt.addOperation( wsdlOp );

	return wsdlOp;
}
 
Example #7
Source File: ServiceWSDLBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testPingMeOperation() throws Exception {
    setupWSDL(WSDL_PATH);
    PortType portType = newDef.getPortType(new QName(newDef.getTargetNamespace(),
        "Greeter"));
    Operation pingMe = portType.getOperation("pingMe", "pingMeRequest", "pingMeResponse");
    assertNotNull(pingMe);
    assertEquals("pingMe", pingMe.getName());
    Input input = pingMe.getInput();
    assertNotNull(input);
    assertEquals("pingMeRequest", input.getName());
    Message message = input.getMessage();
    assertNotNull(message);
    assertEquals("pingMeRequest", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("in", message.getPart("in").getName());
    Output output = pingMe.getOutput();
    assertNotNull(output);
    assertEquals("pingMeResponse", output.getName());
    message = output.getMessage();
    assertNotNull(message);
    assertEquals("pingMeResponse", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(message.getParts().size(), 1);
    assertEquals("out", message.getPart("out").getName());
    assertEquals(1, pingMe.getFaults().size());
    Fault fault = pingMe.getFault("pingMeFault");
    assertNotNull(fault);
    assertEquals("pingMeFault", fault.getName());
    message = fault.getMessage();
    assertNotNull(message);
    assertEquals("pingMeFault", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("faultDetail", message.getPart("faultDetail").getName());
    assertNull(message.getPart("faultDetail").getTypeName());
}
 
Example #8
Source File: ServiceWSDLBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testGreetMeOperation() throws Exception {
    setupWSDL(WSDL_PATH);
    PortType portType = newDef.getPortType(new QName(newDef.getTargetNamespace(),
        "Greeter"));
    Operation greetMe = portType.getOperation("greetMe", "greetMeRequest", "greetMeResponse");
    assertNotNull(greetMe);
    assertEquals("greetMe", greetMe.getName());
    Input input = greetMe.getInput();
    assertNotNull(input);
    assertEquals("greetMeRequest", input.getName());
    Message message = input.getMessage();
    assertNotNull(message);
    assertEquals("greetMeRequest", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("in", message.getPart("in").getName());
    Output output = greetMe.getOutput();
    assertNotNull(output);
    assertEquals("greetMeResponse", output.getName());
    message = output.getMessage();
    assertNotNull(message);
    assertEquals("greetMeResponse", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("out", message.getPart("out").getName());
    assertEquals(0, greetMe.getFaults().size());

}
 
Example #9
Source File: ServiceWSDLBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testSayHiOperation() throws Exception {
    setupWSDL(WSDL_PATH);
    PortType portType = newDef.getPortType(new QName(newDef.getTargetNamespace(),
        "Greeter"));
    Collection<Operation> operations =
        CastUtils.cast(
            portType.getOperations(), Operation.class);

    assertEquals(4, operations.size());
    Operation sayHi = portType.getOperation("sayHi", "sayHiRequest", "sayHiResponse");
    assertNotNull(sayHi);
    assertEquals(sayHi.getName(), "sayHi");
    Input input = sayHi.getInput();
    assertNotNull(input);
    assertEquals("sayHiRequest", input.getName());
    Message message = input.getMessage();
    assertNotNull(message);
    assertEquals("sayHiRequest", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("in", message.getPart("in").getName());
    Output output = sayHi.getOutput();
    assertNotNull(output);
    assertEquals("sayHiResponse", output.getName());
    message = output.getMessage();
    assertNotNull(message);
    assertEquals("sayHiResponse", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("out", message.getPart("out").getName());
    assertEquals(0, sayHi.getFaults().size());

}
 
Example #10
Source File: WSDLHelper.java    From cxf with Apache License 2.0 5 votes vote down vote up
public List<Part> getInMessageParts(Operation operation) {
    Input input = operation.getInput();
    List<Part> partsList = new ArrayList<>();
    if (input != null && input.getMessage() != null) {
        Collection<Part> parts = CastUtils.cast(input.getMessage().getParts().values());
        for (Part p : parts) {
            partsList.add(p);
        }
    }
    return partsList;
}
 
Example #11
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static BindingInput getBindingInput(Input input, Definition wsdlDefinition,
                                            ExtensionRegistry extReg) throws Exception {
    BindingInput bi = wsdlDefinition.createBindingInput();
    bi.setName(input.getName());
    bi.addExtensibilityElement(getSoapBody(BindingInput.class, extReg));
    return bi;
}
 
Example #12
Source File: WSDLToXMLProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private BindingInput getBindingInput(Input input, String operationName) throws ToolException {
    BindingInput bi = wsdlDefinition.createBindingInput();
    bi.setName(input.getName());
    //This ext element in some scenario is optional, but if provided, won't cause error
    bi.addExtensibilityElement(getXMLBody(BindingInput.class, operationName));
    return bi;
}
 
Example #13
Source File: WSDLToSoapProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private BindingInput getBindingInput(Input input) throws ToolException {
    BindingInput bi = wsdlDefinition.createBindingInput();
    bi.setName(input.getName());
    // As command line won't specify the details of body/header for message
    // parts
    // All input message's parts will be added into one soap body element
    bi.addExtensibilityElement(getSoapBody(BindingInput.class));
    return bi;
}
 
Example #14
Source File: OperationVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Message generateInputMessage(Operation operation, BindingOperation bindingOperation) {
    Message msg = definition.createMessage();
    QName msgName;
    if (!mapper.isDefaultMapping()) {
        //mangle the message name
        //REVISIT, do we put in the entire scope for mangling
        msgName = new QName(definition.getTargetNamespace(),
                            getScope().tail() + "." + operation.getName());
    } else {
        msgName = new QName(definition.getTargetNamespace(), operation.getName());
    }
    msg.setQName(msgName);
    msg.setUndefined(false);

    String inputName = operation.getName() + REQUEST_SUFFIX;
    Input input = definition.createInput();
    input.setName(inputName);
    input.setMessage(msg);

    BindingInput bindingInput = definition.createBindingInput();
    bindingInput.setName(inputName);

    bindingOperation.setBindingInput(bindingInput);
    operation.setInput(input);

    definition.addMessage(msg);

    return msg;
}
 
Example #15
Source File: XTeeSoapProvider.java    From j-road with Apache License 2.0 5 votes vote down vote up
@Override
protected void populateBindingInput(Definition definition, BindingInput bindingInput, Input input)
    throws WSDLException {
  for (SOAPHeader header : makeHeaders(definition)) {
    bindingInput.addExtensibilityElement(header);
  }
  super.populateBindingInput(definition, bindingInput, input);
}
 
Example #16
Source File: PublishMetadataRunnable.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private Collection<String> getAllPaths() throws URISyntaxException {
    final Set<String> paths = new HashSet<String>();
    final Set<QName> portTypes = new HashSet<QName>();
    final Set<QName> alreadyCreated = new HashSet<QName>();
    for (Binding binding : (Collection<Binding>) wsdlDefinition.getAllBindings().values()) {
        final QName portType = binding.getPortType().getQName();
        if (portTypes.add(portType)) {
            for (BindingOperation operation : (Collection<BindingOperation>) binding.getBindingOperations()) {
                Operation oper = operation.getOperation();
                Input inDef = oper.getInput();
                if (inDef != null) {
                    Message inMsg = inDef.getMessage();
                    addParamsToPath(portType, oper, inMsg, paths, alreadyCreated);
                }

                Output outDef = oper.getOutput();
                if (outDef != null) {
                    Message outMsg = outDef.getMessage();
                    addParamsToPath(portType, oper, outMsg, paths, alreadyCreated);
                }
                for (Fault fault : (Collection<Fault>) oper.getFaults().values()) {
                    Message faultMsg = fault.getMessage();
                    addParamsToPath(portType, oper, faultMsg, paths, alreadyCreated);
                }
            }
        }
    }
    return paths;
}
 
Example #17
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected void buildPortTypeOperation(PortType portType,
                                      Collection<OperationInfo> operationInfos,
                                      final Definition def) {
    for (OperationInfo operationInfo : operationInfos) {
        Operation operation = null;
        try {
            operation = operationInfo.getProperty(
                WSDLServiceBuilder.WSDL_OPERATION, Operation.class);
        } catch (ClassCastException e) {
            // do nothing
        }

        if (operation == null) {
            operation = def.createOperation();
            addDocumentation(operation, operationInfo.getDocumentation());
            operation.setUndefined(false);
            operation.setName(operationInfo.getName().getLocalPart());
            addNamespace(operationInfo.getName().getNamespaceURI(), def);
            if (operationInfo.isOneWay()) {
                operation.setStyle(OperationType.ONE_WAY);
            }
            addExtensibilityElements(def, operation, getWSDL11Extensors(operationInfo));
            Input input = def.createInput();
            addDocumentation(input, operationInfo.getInput().getDocumentation());
            input.setName(operationInfo.getInputName());
            Message message = def.createMessage();
            buildMessage(message, operationInfo.getInput(), def);
            this.addExtensibilityAttributes(def, input, getInputExtensionAttributes(operationInfo));
            this.addExtensibilityElements(def, input, getWSDL11Extensors(operationInfo.getInput()));
            input.setMessage(message);
            operation.setInput(input);
            operation.setParameterOrdering(operationInfo.getParameterOrdering());

            if (operationInfo.getOutput() != null) {
                Output output = def.createOutput();
                addDocumentation(output, operationInfo.getOutput().getDocumentation());
                output.setName(operationInfo.getOutputName());
                message = def.createMessage();
                buildMessage(message, operationInfo.getOutput(), def);
                this.addExtensibilityAttributes(def, output, getOutputExtensionAttributes(operationInfo));
                this.addExtensibilityElements(def, output, getWSDL11Extensors(operationInfo.getOutput()));
                output.setMessage(message);
                operation.setOutput(output);
            }
            //loop to add fault
            Collection<FaultInfo> faults = operationInfo.getFaults();
            Fault fault = null;
            for (FaultInfo faultInfo : faults) {
                fault = def.createFault();
                addDocumentation(fault, faultInfo.getDocumentation());
                fault.setName(faultInfo.getFaultName().getLocalPart());
                message = def.createMessage();
                buildMessage(message, faultInfo, def);
                this.addExtensibilityAttributes(def, fault, faultInfo.getExtensionAttributes());
                this.addExtensibilityElements(def, fault, getWSDL11Extensors(faultInfo));
                fault.setMessage(message);
                operation.addFault(fault);
            }
        }
        portType.addOperation(operation);
    }
}
 
Example #18
Source File: WsdlVisitor.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void walkTree() {
    begin();
    try {
        visit(definition);
        for (Iterator iterator = definition.getImports().entrySet().iterator(); iterator.hasNext(); ) {
            Map.Entry entry = (Map.Entry) iterator.next();
            String namespaceURI = (String) entry.getKey();
            List importsForNamespace = (List) entry.getValue();
            for (Iterator iterator1 = importsForNamespace.iterator(); iterator1.hasNext(); ) {
                Import anImport = (Import) iterator1.next();
                visit(anImport);
            }
        }
        visit(definition.getTypes());
        Collection messages = definition.getMessages().values();
        for (Iterator iterator = messages.iterator(); iterator.hasNext(); ) {
            Message message = (Message) iterator.next();
            visit(message);
            Collection parts = message.getParts().values();
            for (Iterator iterator2 = parts.iterator(); iterator2.hasNext(); ) {
                Part part = (Part) iterator2.next();
                visit(part);
            }
        }
        Collection services = definition.getServices().values();
        for (Iterator iterator = services.iterator(); iterator.hasNext(); ) {
            Service service = (Service) iterator.next();
            visit(service);
            Collection ports = service.getPorts().values();
            for (Iterator iterator1 = ports.iterator(); iterator1.hasNext(); ) {
                Port port = (Port) iterator1.next();
                visit(port);
                Binding binding = port.getBinding();
                visit(binding);
                List bindingOperations = binding.getBindingOperations();
                for (int i = 0; i < bindingOperations.size(); i++) {
                    BindingOperation bindingOperation = (BindingOperation) bindingOperations.get(i);
                    visit(bindingOperation);
                    visit(bindingOperation.getBindingInput());
                    visit(bindingOperation.getBindingOutput());
                    Collection bindingFaults = bindingOperation.getBindingFaults().values();
                    for (Iterator iterator2 = bindingFaults.iterator(); iterator2.hasNext(); ) {
                        BindingFault bindingFault = (BindingFault) iterator2.next();
                        visit(bindingFault);
                    }

                }
                PortType portType = binding.getPortType();
                visit(portType);
                List operations = portType.getOperations();
                for (int i = 0; i < operations.size(); i++) {
                    Operation operation = (Operation) operations.get(i);
                    visit(operation);
                    {
                        Input input = operation.getInput();
                        visit(input);
                    }
                    {
                        Output output = operation.getOutput();
                        visit(output);
                    }
                    Collection faults = operation.getFaults().values();
                    for (Iterator iterator2 = faults.iterator(); iterator2.hasNext(); ) {
                        Fault fault = (Fault) iterator2.next();
                        visit(fault);
                    }

                }
            }
        }
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    } finally {
        end();
    }
}
 
Example #19
Source File: WsdlVisitor.java    From tomee with Apache License 2.0 4 votes vote down vote up
protected void visit(Input input) {
}