javax.wsdl.Message Java Examples

The following examples show how to use javax.wsdl.Message. 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: WsdlOpFaultList.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Create a WsdlOpFault from the Fault.
 *
 * @param fault
 *          Fault to process.
 * @return WsdlOpFault Result of processing.
 */
@SuppressWarnings( "unchecked" )
private WsdlOpFault getFault( Fault fault ) throws KettleStepException {
  Message m = fault.getMessage();

  // a fault should only have one message part.
  Map<?, Part> partMap = m.getParts();
  if ( partMap.size() != 1 ) {
    throw new IllegalArgumentException( "Invalid part count for fault!!" );
  }
  Part faultPart = partMap.values().iterator().next();
  boolean complexType = false;

  // type of fault is specified either in Part's type or element attribute.
  QName type = faultPart.getTypeName();
  if ( type == null ) {
    type = faultPart.getElementName();
    Element schemaElement = _wsdlTypes.findNamedElement( type );
    type = _wsdlTypes.getTypeQName( schemaElement.getAttribute( "type" ) );
    complexType = true;
  }
  return new WsdlOpFault( fault.getName(), type, complexType, _wsdlTypes );
}
 
Example #2
Source File: AttributeVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private Message generateMessage(XmlSchemaElement element, String name) {
    Part part = definition.createPart();
    part.setName(PART_NAME);
    part.setElementName(element.getQName());

    Message result = definition.createMessage();

    QName qName = new QName(definition.getTargetNamespace(), name);
    if (definition.getMessage(qName) != null) {
        String newName = getScope().toString() + "." + name;
        qName = new QName(definition.getTargetNamespace(), newName);
    }


    result.setQName(qName);
    result.addPart(part);
    result.setUndefined(false);
    definition.addMessage(result);

    return result;
}
 
Example #3
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 #4
Source File: WsdlOpFaultList.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Create a WsdlOpFault from the Fault.
 *
 * @param fault Fault to process.
 * @return WsdlOpFault Result of processing.
 */
@SuppressWarnings( "unchecked" )
private WsdlOpFault getFault( Fault fault ) throws HopTransformException {
  Message m = fault.getMessage();

  // a fault should only have one message part.
  Map<?, Part> partMap = m.getParts();
  if ( partMap.size() != 1 ) {
    throw new IllegalArgumentException( "Invalid part count for fault!!" );
  }
  Part faultPart = partMap.values().iterator().next();
  boolean complexType = false;

  // type of fault is specified either in Part's type or element attribute.
  QName type = faultPart.getTypeName();
  if ( type == null ) {
    type = faultPart.getElementName();
    Element schemaElement = _wsdlTypes.findNamedElement( type );
    type = _wsdlTypes.getTypeQName( schemaElement.getAttribute( "type" ) );
    complexType = true;
  }
  return new WsdlOpFault( fault.getName(), type, complexType, _wsdlTypes );
}
 
Example #5
Source File: ExceptionVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void createFaultMessage(QName qname) {
    String exceptionName = qname.getLocalPart();
    // messages
    Message faultMsg = definition.createMessage();

    faultMsg.setQName(new QName(definition.getTargetNamespace(), exceptionName));
    faultMsg.setUndefined(false);
    // message - part
    Part part = definition.createPart();
    part.setName("exception");
    part.setElementName(qname);
    faultMsg.addPart(part);

    //add the fault element namespace to the definition
    String nsURI = qname.getNamespaceURI();
    manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(nsURI), nsURI);

    definition.addMessage(faultMsg);
}
 
Example #6
Source File: UniqueBodyPartsValidator.java    From cxf with Apache License 2.0 6 votes vote down vote up
private boolean isUniqueBodyPart(String operationName, Message msg,
                                 Collection<String> headers, QName bindingName) {
    List<Part> partList = CastUtils.cast(msg.getOrderedParts(null));
    for (Part part : partList) {
        if (headers.contains(part.getName())) {
            continue;
        }
        if (part.getElementName() == null) {
            return true;
        }
        String opName = getOperationNameWithSamePart(operationName, part);
        if (opName != null) {
            addErrorMessage("Non unique body parts, operation " + "[ " + opName + " ] "
                            + "and operation [ " + operationName + " ] in binding "
                            + bindingName.toString()
                            + " have the same body block: "
                            + part.getElementName());
            return false;
        }
        //just need to check the first element
        return true;
    }
    return true;
}
 
Example #7
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void buildMessage(Message message,
                            AbstractMessageContainer messageContainer,
                            final Definition def) {
    addDocumentation(message, messageContainer.getMessageDocumentation());
    message.setQName(messageContainer.getName());
    message.setUndefined(false);
    def.addMessage(message);

    List<MessagePartInfo> messageParts = messageContainer.getMessageParts();
    Part messagePart = null;
    for (MessagePartInfo messagePartInfo : messageParts) {
        messagePart = def.createPart();
        messagePart.setName(messagePartInfo.getName().getLocalPart());
        if (messagePartInfo.isElement()) {
            messagePart.setElementName(messagePartInfo.getElementQName());
            addNamespace(messagePartInfo.getElementQName().getNamespaceURI(), def);
        } else if (messagePartInfo.getTypeQName() != null) {
            messagePart.setTypeName(messagePartInfo.getTypeQName());
            addNamespace(messagePartInfo.getTypeQName().getNamespaceURI(), def);
        }
        message.addPart(messagePart);
    }
}
 
Example #8
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 #9
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 #10
Source File: PublishMetadataRunnable.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
private static List<QName> getMessageParts(Message msg) {
    List<QName> result = new ArrayList<QName>();
    @SuppressWarnings("unchecked")
    Collection<Part> values = msg.getParts().values();
    if (values == null || values.isEmpty()) {
        return result;
    }
    Iterator<Part> iterator = values.iterator();
    while (iterator.hasNext()) {
        Part part = iterator.next();
        if (part.getElementName() != null) {
            result.add(part.getElementName());
        } else if (part.getTypeName() != null) {
            result.add(part.getTypeName());
        }
    }
    return result;
}
 
Example #11
Source File: PublishMetadataRunnable.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
private static void addParamsToPath(final QName portType, Operation oper, Message msg, final Set<String> paths,
        final Set<QName> alreadyCreated) throws URISyntaxException {
    if (msg != null) {
        List<QName> messageParts = getMessageParts(msg);
        if (messageParts.isEmpty()) {
            return;
        }
        for(QName messagePart : messageParts) {
            if (alreadyCreated.add(messagePart)) {
                String folderPath = FolderNameUtil.getImportedXmlSchemaPath(messagePart.getNamespaceURI(),
                        portType.getLocalPart(), oper.getName());
                paths.add(folderPath);
            }
        }
    }
}
 
Example #12
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 #13
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 #14
Source File: ServiceWSDLBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoBodyParts() throws Exception {
    setupWSDL(NO_BODY_PARTS_WSDL_PATH);
    QName messageName = new QName("urn:org:apache:cxf:no_body_parts/wsdl",
        "operation1Request");
    Message message = newDef.getMessage(messageName);
    Part part = message.getPart("mimeAttachment");
    assertNotNull(part.getTypeName());
}
 
Example #15
Source File: WSDLServiceBuilder.java    From cxf with Apache License 2.0 5 votes vote down vote up
private List<ServiceInfo> buildServices(Definition d,
                                        QName name,
                                        QName endpointName,
                                        DescriptionInfo description) {
    Service service = d.getService(name);
    if (service == null) {
        org.apache.cxf.common.i18n.Message msg =
            new org.apache.cxf.common.i18n.Message("MISSING_SERVICE",
                                                   LOG,
                                                   name);
        throw new WSDLRuntimeException(msg);
    }
    return buildServices(d, service, endpointName, description);
}
 
Example #16
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 #17
Source File: OperationVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void createFaultMessage(CorbaTypeImpl corbaType,
                                Operation operation,
                                BindingOperation bindingOperation,
                                QName elementQName) {
    String exceptionName = corbaType.getQName().getLocalPart();

    Definition faultDef = manager.getWSDLDefinition(elementQName.getNamespaceURI());
    if (faultDef == null) {
        faultDef = definition;
    }
    Message faultMsg = faultDef.getMessage(new QName(faultDef.getTargetNamespace(), exceptionName));
    if (faultMsg == null) {
        throw new RuntimeException("Fault message for exception " + exceptionName + " not found");
    }

    // porttype - operation - fault
    Fault fault = definition.createFault();
    fault.setMessage(faultMsg);
    fault.setName(faultMsg.getQName().getLocalPart());
    operation.addFault(fault);

    // binding - operation - corba:operation - corba:raises
    RaisesType raisesType = new RaisesType();
    raisesType.setException(new QName(typeMap.getTargetNamespace(),
                                      exceptionName));
    corbaOperation.getRaises().add(raisesType);

    // binding - operation - fault
    BindingFault bindingFault = definition.createBindingFault();
    bindingFault.setName(faultMsg.getQName().getLocalPart());
    bindingOperation.addBindingFault(bindingFault);

    //add the fault element namespace to the definition
    String nsURI = elementQName.getNamespaceURI();
    manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(nsURI), nsURI);
}
 
Example #18
Source File: OperationVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Part generateOutputPart(Message outputMessage, XmlSchemaElement element) {
    // message - part
    Part part = definition.createPart();
    part.setName(OUT_PARAMETER);
    part.setElementName(element.getQName());
    outputMessage.addPart(part);
    return part;
}
 
Example #19
Source File: OperationVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Part generateInputPart(Message inputMessage, XmlSchemaElement element) {
    // message - part
    Part part = definition.createPart();
    part.setName(IN_PARAMETER);
    part.setElementName(element.getQName());
    inputMessage.addPart(part);
    return part;
}
 
Example #20
Source File: OperationVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Message generateOutputMessage(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() + RESPONSE_SUFFIX);
    } else {
        msgName = new QName(definition.getTargetNamespace(),
                            operation.getName() + RESPONSE_SUFFIX);
    }
    msg.setQName(msgName);
    msg.setUndefined(false);

    String outputName = operation.getName() + RESPONSE_SUFFIX;
    Output output = definition.createOutput();
    output.setName(outputName);
    output.setMessage(msg);

    BindingOutput bindingOutput = definition.createBindingOutput();
    bindingOutput.setName(outputName);

    bindingOperation.setBindingOutput(bindingOutput);
    operation.setOutput(output);

    definition.addMessage(msg);

    return msg;
}
 
Example #21
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 #22
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 #23
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 #24
Source File: HeavyweightOperationInfoBuilder.java    From tomee with Apache License 2.0 5 votes vote down vote up
private Part getWrappedPart(Message message) throws OpenEJBException {
    // a wrapped element can only have one part
    Collection parts = message.getParts().values();
    if (parts.size() != 1) {
        throw new OpenEJBException("message " + message.getQName() + " has " + parts.size() +
            " parts and should only have one as wrapper style mapping is specified for operation " +
            operationName);
    }
    return (Part) parts.iterator().next();
}
 
Example #25
Source File: AttributeVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void generateGetter(AST typeNode, AST nameNode) {
    // generate wrapped doc element in parameter
    XmlSchemaElement inParameters =
        generateWrappedDocElement(null,
                                  GETTER_PREFIX + nameNode.toString(),
                                  PARAM_NAME);
    // generate wrapped doc element out parameter
    XmlSchemaElement outParameters =
        generateWrappedDocElement(typeNode,
                                  GETTER_PREFIX + nameNode.toString() + RESULT_POSTFIX,
                                  RETURN_PARAM_NAME);

    // generate input message
    Message inMsg = generateMessage(inParameters,
                                    GETTER_PREFIX + nameNode.toString());
    // generate output message
    Message outMsg = generateMessage(outParameters,
                                     GETTER_PREFIX + nameNode.toString() + RESPONSE_POSTFIX);

    // generate operation
    String name = GETTER_PREFIX + nameNode.toString();
    Operation op = generateOperation(name, inMsg, outMsg);


    // generate corba return param
    ArgType corbaReturn = generateCorbaReturnParam(typeNode);

    // generate corba operation
    OperationType corbaOp = generateCorbaOperation(op, null, corbaReturn);

    // generate binding
    generateCorbaBindingOperation(binding, op, corbaOp);
}
 
Example #26
Source File: OperationInfo.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
private static ParameterInfo getParameterFromMessage(Message msg) {
    ParameterInfo parameterRoot = new ParameterInfo();
    List<Part> msgParts = msg.getOrderedParts(null);
    if (msgParts.size() > 1) {
        parameterRoot.setName(ParameterInfo.MULTIPART);
    } else if (msgParts.size() == 1) {
        Part part = msgParts.iterator().next();
        if (part.getElementName() != null) {
            parameterRoot.setName(part.getElementName());
        } else if (part.getTypeName() != null) {
            parameterRoot.setName(part.getTypeName());
        }
    }
    return parameterRoot;
}
 
Example #27
Source File: SoapProtocol.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String getOutputMessageRootElementName( String operationName )
	throws IOException {
	String elementName = operationName + ((received) ? "Response" : "");
	Port port = getWSDLPort();
	if( port != null ) {
		try {
			Operation operation = port.getBinding().getPortType().getOperation( operationName, null, null );
			List< ExtensibilityElement > listExt;
			Message soapMessage;
			if( received ) {
				// We are sending a response
				soapMessage = operation.getOutput().getMessage();
				listExt = getWSDLPort().getBinding().getBindingOperation( operationName, null, null )
					.getBindingOutput().getExtensibilityElements();
			} else {
				// We are sending a request
				soapMessage = operation.getInput().getMessage();
				listExt = getWSDLPort().getBinding().getBindingOperation( operationName, null, null )
					.getBindingInput().getExtensibilityElements();
			}
			for( ExtensibilityElement element : listExt ) {
				if( element instanceof SOAPBodyImpl ) {
					SOAPBodyImpl sBodyImpl = (SOAPBodyImpl) element;
					if( sBodyImpl.getParts().size() > 0 ) {
						String partName = sBodyImpl.getParts().get( 0 ).toString();
						elementName = soapMessage.getPart( partName ).getElementName().getLocalPart();
					} else {
						Part part = ((Entry< String, Part >) soapMessage.getParts().entrySet().iterator().next())
							.getValue();
						elementName = part.getElementName().getLocalPart();
					}

				}
			}

		} catch( Exception e ) {
		}
	}
	return elementName;
}
 
Example #28
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Message addRequestMessage( Definition localDef, OperationDeclaration op ) {

		Message inputMessage = localDef.createMessage();
		inputMessage.setUndefined( false );

		Part inputPart = localDef.createPart();
		inputPart.setName( "body" );
		try {
			// adding wsdl_types related to this message
			if( op instanceof OneWayOperationDeclaration ) {
				OneWayOperationDeclaration op_ow = (OneWayOperationDeclaration) op;

				// set the message name as the name of the jolie request message type
				inputMessage.setQName( new QName( tns, op_ow.requestType().id() ) );
				addMessageType( op_ow.requestType(), op_ow.id() );

			} else {
				RequestResponseOperationDeclaration op_rr = (RequestResponseOperationDeclaration) op;
				// set the message name as the name of the jolie request message type
				inputMessage.setQName( new QName( tns, op_rr.requestType().id() ) );
				addMessageType( op_rr.requestType(), op_rr.id() );

			}
			// set the input part as the operation name
			inputPart.setElementName( new QName( tnsSchema, op.id() ) );

			inputMessage.addPart( inputPart );
			inputMessage.setUndefined( false );

			localDef.addMessage( inputMessage );
		} catch( Exception e ) {
			e.printStackTrace();
		}
		return inputMessage;
	}
 
Example #29
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Message addResponseMessage( Definition localDef, OperationDeclaration op ) {

		Message outputMessage = localDef.createMessage();
		outputMessage.setUndefined( false );

		Part outputPart = localDef.createPart();
		outputPart.setName( "body" );

		// adding wsdl_types related to this message
		try {
			RequestResponseOperationDeclaration op_rr = (RequestResponseOperationDeclaration) op;
			String outputPartName = op_rr.id() + "Response";
			// set the message name as the name of the jolie response message type
			outputMessage.setQName( new QName( tns, op_rr.responseType().id() ) );
			addMessageType( op_rr.responseType(), outputPartName );

			outputPart.setElementName( new QName( tnsSchema, outputPartName ) );

			outputMessage.addPart( outputPart );
			outputMessage.setUndefined( false );

			localDef.addMessage( outputMessage );
		} catch( Exception e ) {
			e.printStackTrace();
		}
		return outputMessage;

	}
 
Example #30
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Message addFaultMessage( Definition localDef, TypeDefinition tp ) {
	Message faultMessage = localDef.createMessage();
	faultMessage.setUndefined( false );

	// set the fault message name as the name of the fault jolie message type
	faultMessage.setQName( new QName( tns, tp.id() ) );

	Part faultPart = localDef.createPart();
	faultPart.setName( "body" );

	String faultPartName = tp.id();

	try {
		// adding wsdl_types related to this message
		addMessageType( tp, faultPartName );

		faultPart.setElementName( new QName( tnsSchema, faultPartName ) );
		faultMessage.addPart( faultPart );
		faultMessage.setUndefined( false );

		localDef.addMessage( faultMessage );
	} catch( Exception e ) {
		e.printStackTrace();
	}
	return faultMessage;

}