javax.wsdl.Part Java Examples

The following examples show how to use javax.wsdl.Part. 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: WsdlOpParameterList.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Add a parameter to this list.
 *
 * @param p           Message part defining the parameter.
 * @param requestPart tue if this parameter is part of an reqest message.
 * @return true if this collection was modified as a result of this call.
 */
protected boolean add( Part p, boolean requestPart ) throws HopTransformException {

  List<WsdlOpParameter> params = getParameter( p, requestPart );
  for ( WsdlOpParameter op : params ) {

    if ( _headerNames.contains( op.getName().getLocalPart() ) ) {
      op.setHeader();
    }

    if ( requestPart ) {
      // just set mode and add
      op.setMode( op.getMode() ); // TODO: WTF??
      add( op );
    } else {
      addOutputParameter( op );
    }
  }
  return true;
}
 
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: 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 #4
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 #5
Source File: WSDLToCorbaHelper.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected XmlSchemaType lookUpType(Part part) {
    XmlSchemaType schemaType = null;
    for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
        if (part.getElementName() != null) {
            XmlSchemaElement schemaElement = xmlSchema.getElementByName(part.getElementName());
            if (schemaElement != null) {
                schemaType = schemaElement.getSchemaType();
            }
        } else {
            if (part.getTypeName() != null) {
                schemaType = xmlSchema.getTypeByName(part.getTypeName());
            }
        }
        if (schemaType != null) {
            return schemaType;
        }
    }

    return schemaType;
}
 
Example #6
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 #7
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 #8
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 #9
Source File: HeavyweightOperationInfoBuilder.java    From tomee with Apache License 2.0 6 votes vote down vote up
private XmlElementInfo getWrapperChild(Part part, String wsdlMessagePartName) throws OpenEJBException {
    // get the part name
    QName elementName = part.getElementName();
    wrapperElementQNames.add(elementName);

    // get the wrapper element
    XmlElementInfo wrapperElement = schemaInfo.elements.get(elementName);
    if (wrapperElement == null) {
        throw new OpenEJBException("No global element named " + elementName + " for operation " + operationName);
    }

    // get the wrapper type
    XmlTypeInfo wrapperType = schemaInfo.types.get(wrapperElement.xmlType);
    if (wrapperType == null) {
        throw new OpenEJBException("Can not find type " + wrapperElement.xmlType + " for element " + wrapperElement.qname + ", known types: " + schemaInfo.types.keySet());
    }

    // get the part type
    for (XmlElementInfo wrapperChild : wrapperType.elements.values()) {
        if (wrapperChild.qname.getLocalPart().equals(wsdlMessagePartName)) {
            return wrapperChild;
        }
    }
    throw new OpenEJBException("Global element named " + elementName + " does not define a child element named " + wsdlMessagePartName + " required by the operation " + operationName);
}
 
Example #10
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 #11
Source File: WsdlOpParameterList.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Add a parameter to this list.
 *
 * @param p
 *          Message part defining the parameter.
 * @param requestPart
 *          tue if this parameter is part of an reqest message.
 * @return true if this collection was modified as a result of this call.
 */
protected boolean add( Part p, boolean requestPart ) throws KettleStepException {

  List<WsdlOpParameter> params = getParameter( p, requestPart );
  for ( WsdlOpParameter op : params ) {

    if ( _headerNames.contains( op.getName().getLocalPart() ) ) {
      op.setHeader();
    }

    if ( requestPart ) {
      // just set mode and add
      op.setMode( op.getMode() ); // TODO: WTF??
      add( op );
    } else {
      addOutputParameter( op );
    }
  }
  return true;
}
 
Example #12
Source File: WsdlOpParameterList.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Generate a WsdlOpParameter from the message part.
 *
 * @param part
 *          A list of message part.
 * @param requesPart
 *          true if part from request message.
 */
private List<WsdlOpParameter> getParameter( Part part, boolean requesPart ) throws KettleStepException {

  List<WsdlOpParameter> params = new ArrayList<WsdlOpParameter>();

  if ( part.getElementName() != null ) {
    if ( WsdlUtils.isWrappedParameterStyle( _operation.getName(), !requesPart, part.getName() ) ) {
      _parameterStyle = WsdlOperation.SOAPParameterStyle.WRAPPED;
    }
    params.addAll( resolvePartElement( part ) );
  } else {
    params.add( new WsdlOpParameter( part.getName(), part.getTypeName(), _wsdlTypes.findNamedType( part
      .getTypeName() ), _wsdlTypes ) );
  }
  return params;
}
 
Example #13
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 #14
Source File: WsdlOpParameterList.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Generate a WsdlOpParameter from the message part.
 *
 * @param part       A list of message part.
 * @param requesPart true if part from request message.
 */
private List<WsdlOpParameter> getParameter( Part part, boolean requesPart ) throws HopTransformException {

  List<WsdlOpParameter> params = new ArrayList<WsdlOpParameter>();

  if ( part.getElementName() != null ) {
    if ( WsdlUtils.isWrappedParameterStyle( _operation.getName(), !requesPart, part.getName() ) ) {
      _parameterStyle = WsdlOperation.SOAPParameterStyle.WRAPPED;
    }
    params.addAll( resolvePartElement( part ) );
  } else {
    params.add( new WsdlOpParameter( part.getName(), part.getTypeName(), _wsdlTypes.findNamedType( part
      .getTypeName() ), _wsdlTypes ) );
  }
  return params;
}
 
Example #15
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 #16
Source File: LightWeightMappingValidator.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
protected void visit(Fault fault) {
    Part message = fault.getMessage().getPart("message");
    if (message == null) {
        context.addFailure(new ValidationFailure("The fault message must contain one part named 'message' : " + fault.getName()));
    } else if (!XSD_STRING.equals(message.getTypeName())) {
        context.addFailure(new ValidationFailure("The fault message must contain one part of type 'xsd:string' : " + fault.getName()));
    }
}
 
Example #17
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 #18
Source File: WSDLManagerImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testBuildImportedWSDL() throws Exception {
    String wsdlUrl = getClass().getResource("hello_world_services.wsdl").toString();

    WSDLManager builder = new WSDLManagerImpl();
    Definition def = builder.getDefinition(wsdlUrl);

    assertNotNull(def);
    Map<?, ?> services = def.getServices();
    assertNotNull(services);
    assertEquals(1, services.size());

    String serviceQName = "http://apache.org/hello_world/services";
    Service service = (Service)services.get(new QName(serviceQName, "SOAPService"));
    assertNotNull(service);

    Map<?, ?> ports = service.getPorts();
    assertNotNull(ports);
    assertEquals(1, ports.size());
    Port port = service.getPort("SoapPort");
    assertNotNull(port);

    Binding binding = port.getBinding();
    assertNotNull(binding);
    QName bindingQName = new QName("http://apache.org/hello_world/bindings", "SOAPBinding");
    assertEquals(bindingQName, binding.getQName());
    PortType portType = binding.getPortType();
    assertNotNull(portType);
    QName portTypeQName = new QName("http://apache.org/hello_world", "Greeter");
    assertEquals(portTypeQName, portType.getQName());
    Operation op1 = portType.getOperation("sayHi", "sayHiRequest", "sayHiResponse");
    assertNotNull(op1);
    QName messageQName = new QName("http://apache.org/hello_world/messages", "sayHiRequest");
    assertEquals(messageQName, op1.getInput().getMessage().getQName());

    Part part = op1.getInput().getMessage().getPart("in");
    assertNotNull(part);
    assertEquals(new QName("http://apache.org/hello_world/types", "sayHi"), part.getElementName());
}
 
Example #19
Source File: WSDLHelper.java    From cxf with Apache License 2.0 5 votes vote down vote up
public List<Part> getOutMessageParts(Operation operation) {
    Output output = operation.getOutput();
    List<Part> partsList = new ArrayList<>();
    if (output != null && output.getMessage() != null) {
        Collection<Part> parts = CastUtils.cast(output.getMessage().getParts().values());
        for (Part p : parts) {
            partsList.add(p);
        }
    }
    return partsList;
}
 
Example #20
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 #21
Source File: WSDLDefinitionBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testBuildImportedWSDL() throws Exception {
    String wsdlUrl = getClass().getResource("hello_world_services.wsdl").toString();

    WSDLDefinitionBuilder builder = new WSDLDefinitionBuilder(BusFactory.getDefaultBus());
    Definition def = builder.build(wsdlUrl);

    assertNotNull(def);
    Map<?, ?> services = def.getServices();
    assertNotNull(services);
    assertEquals(1, services.size());

    String serviceQName = "http://apache.org/hello_world/services";
    Service service = (Service)services.get(new QName(serviceQName, "SOAPService"));
    assertNotNull(service);

    Map<?, ?> ports = service.getPorts();
    assertNotNull(ports);
    assertEquals(1, ports.size());
    Port port = service.getPort("SoapPort");
    assertNotNull(port);

    Binding binding = port.getBinding();
    assertNotNull(binding);
    QName bindingQName = new QName("http://apache.org/hello_world/bindings", "SOAPBinding");
    assertEquals(bindingQName, binding.getQName());
    PortType portType = binding.getPortType();
    assertNotNull(portType);
    QName portTypeQName = new QName("http://apache.org/hello_world", "Greeter");
    assertEquals(portTypeQName, portType.getQName());
    Operation op1 = portType.getOperation("sayHi", "sayHiRequest", "sayHiResponse");
    assertNotNull(op1);
    QName messageQName = new QName("http://apache.org/hello_world/messages", "sayHiRequest");
    assertEquals(messageQName, op1.getInput().getMessage().getQName());

    Part part = op1.getInput().getMessage().getPart("in");
    assertNotNull(part);
    assertEquals(new QName("http://apache.org/hello_world/types", "sayHi"), part.getElementName());
}
 
Example #22
Source File: WSDLParameter.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static XmlSchemaElement getElement(Part part, SchemaCollection xmlSchemaList) throws Exception {
    XmlSchemaElement schemaElement = null;

    for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
        if (part.getElementName() != null) {
            schemaElement = findElement(xmlSchema, part.getElementName());
            if (schemaElement != null) {
                return schemaElement;
            }
        }
    }
    return schemaElement;
}
 
Example #23
Source File: WsdlOpParameterList.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Resolve a Part's element attribute value to a concrete XML type.
 *
 * @param p
 *          A message part.
 * @return A list of parameters resulting from the schema type -- typically the list will only contains a single
 *         parameter.
 */
private List<WsdlOpParameter> resolvePartElement( Part p ) throws KettleStepException {

  List<WsdlOpParameter> resolvedParams = new ArrayList<WsdlOpParameter>();
  Element schemaElement = _wsdlTypes.findNamedElement( p.getElementName() );

  if ( schemaElement.hasAttribute( WsdlUtils.ELEMENT_TYPE_ATTR ) ) {
    // this is a simple type
    resolvedParams.add( new WsdlOpParameter( p.getName(), schemaElement, _wsdlTypes ) );
  } else {
    // this is a complex type
    Element complex = DomUtils.getChildElementByName( schemaElement, WsdlUtils.COMPLEX_TYPE_NAME );
    Element sequence = DomUtils.getChildElementByName( complex, WsdlUtils.SEQUENCE_TAG_NAME );

    // may occasionally find a <complex/> tag map to empty but this may be a bug in WSM
    //
    if ( sequence == null ) {
      return resolvedParams;
    }

    List<Element> seqElements = DomUtils.getChildElementsByName( sequence, WsdlUtils.ELEMENT_NAME );

    for ( Element e : seqElements ) {
      WsdlOpParameter op = new WsdlOpParameter( e, _wsdlTypes );

      // special case for bare arrays, change the name of the param
      // to the name of the complex type.
      if ( op.isArray() && _parameterStyle == WsdlOperation.SOAPParameterStyle.BARE ) {
        op.setName( schemaElement.getAttribute( WsdlUtils.NAME_ATTR ), _wsdlTypes );
      }
      resolvedParams.add( op );
    }
  }
  return resolvedParams;
}
 
Example #24
Source File: WSDLParameter.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static XmlSchemaType getType(Part part, SchemaCollection xmlSchemaList) throws Exception {
    XmlSchemaType schemaType = null;

    for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
        if (part.getTypeName() != null) {
            schemaType = findSchemaType(xmlSchema, part.getTypeName());
            if (schemaType != null) {
                return schemaType;
            }
        }
    }

    return schemaType;
}
 
Example #25
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 #26
Source File: WsdlOpParameterList.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * Resolve a Part's element attribute value to a concrete XML type.
 *
 * @param p A message part.
 * @return A list of parameters resulting from the schema type -- typically the list will only contains a single
 * parameter.
 */
private List<WsdlOpParameter> resolvePartElement( Part p ) throws HopTransformException {

  List<WsdlOpParameter> resolvedParams = new ArrayList<WsdlOpParameter>();
  Element schemaElement = _wsdlTypes.findNamedElement( p.getElementName() );

  if ( schemaElement.hasAttribute( WsdlUtils.ELEMENT_TYPE_ATTR ) ) {
    // this is a simple type
    resolvedParams.add( new WsdlOpParameter( p.getName(), schemaElement, _wsdlTypes ) );
  } else {
    // this is a complex type
    Element complex = DomUtils.getChildElementByName( schemaElement, WsdlUtils.COMPLEX_TYPE_NAME );
    Element sequence = DomUtils.getChildElementByName( complex, WsdlUtils.SEQUENCE_TAG_NAME );

    // may occasionally find a <complex/> tag map to empty but this may be a bug in WSM
    //
    if ( sequence == null ) {
      return resolvedParams;
    }

    List<Element> seqElements = DomUtils.getChildElementsByName( sequence, WsdlUtils.ELEMENT_NAME );

    for ( Element e : seqElements ) {
      WsdlOpParameter op = new WsdlOpParameter( e, _wsdlTypes );

      // special case for bare arrays, change the name of the param
      // to the name of the complex type.
      if ( op.isArray() && _parameterStyle == WsdlOperation.SOAPParameterStyle.BARE ) {
        op.setName( schemaElement.getAttribute( WsdlUtils.NAME_ATTR ), _wsdlTypes );
      }
      resolvedParams.add( op );
    }
  }
  return resolvedParams;
}
 
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;

}