Java Code Examples for javax.wsdl.extensions.ExtensibilityElement

The following examples show how to use javax.wsdl.extensions.ExtensibilityElement. These examples are extracted from open source projects. 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 Project: cxf   Source File: RMEndpointTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testGetUsingAddressing() {
    EndpointInfo ei = null;
    control.replay();
    assertNull(rme.getUsingAddressing(ei));
    control.verify();

    control.reset();
    ExtensibilityElement ua = control.createMock(ExtensibilityElement.class);
    ei = control.createMock(EndpointInfo.class);
    List<ExtensibilityElement> noExts = new ArrayList<>();
    List<ExtensibilityElement> exts = new ArrayList<>();
    exts.add(ua);
    EasyMock.expect(ei.getExtensors(ExtensibilityElement.class)).andReturn(noExts);
    BindingInfo bi = control.createMock(BindingInfo.class);
    EasyMock.expect(ei.getBinding()).andReturn(bi).times(2);
    EasyMock.expect(bi.getExtensors(ExtensibilityElement.class)).andReturn(noExts);
    ServiceInfo si = control.createMock(ServiceInfo.class);
    EasyMock.expect(ei.getService()).andReturn(si).times(2);
    EasyMock.expect(si.getExtensors(ExtensibilityElement.class)).andReturn(exts);
    EasyMock.expect(ua.getElementType()).andReturn(Names.WSAW_USING_ADDRESSING_QNAME);
    control.replay();
    assertSame(ua, rme.getUsingAddressing(ei));
}
 
Example 2
Source Project: hop   Source File: WsdlTypes.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Build a list of schema target name spaces which are element form qualified.
 *
 * @return All target name spaces for schemas defined in the WSDL which are element form qualified.
 */
private List<String> getElementFormQualifiedNamespaces() {

  List<String> namespaces = new ArrayList<>();
  List<ExtensibilityElement> schemas = getSchemas();

  for ( ExtensibilityElement schema : schemas ) {
    Element schemaElement = ( (Schema) schema ).getElement();

    if ( schemaElement.hasAttribute( WsdlUtils.ELEMENT_FORM_DEFAULT_ATTR ) ) {
      String v = schemaElement.getAttribute( WsdlUtils.ELEMENT_FORM_DEFAULT_ATTR );
      if ( WsdlUtils.ELEMENT_FORM_QUALIFIED.equalsIgnoreCase( v ) ) {
        namespaces.add( schemaElement.getAttribute( WsdlUtils.TARGET_NAMESPACE_ATTR ) );
      }
    }
  }
  return namespaces;
}
 
Example 3
Source Project: hop   Source File: WsdlTypes.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Get the schema with the specified target namespace.
 *
 * @param targetNamespace target namespace of the schema to get.
 * @return null if not found.
 */
private Schema getSchema( String targetNamespace ) {

  if ( _types == null ) {
    return null;
  }

  List<ExtensibilityElement> schemas = WsdlUtils.findExtensibilityElements( (ElementExtensible) _types, "schema" );

  for ( ExtensibilityElement e : schemas ) {
    Element schemaRoot = ( (Schema) e ).getElement();
    String tns = schemaRoot.getAttribute( "targetNamespace" );
    if ( targetNamespace.equals( tns ) ) {
      return (Schema) e;
    }
  }
  return null;
}
 
Example 4
Source Project: jolie   Source File: SoapProtocol.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseWSDLTypes( XSOMParser schemaParser )
	throws IOException {
	Definition definition = getWSDLDefinition();
	if( definition != null ) {
		Types types = definition.getTypes();
		if( types != null ) {
			List< ExtensibilityElement > list = types.getExtensibilityElements();
			for( ExtensibilityElement element : list ) {
				if( element instanceof SchemaImpl ) {
					Element schemaElement = ((SchemaImpl) element).getElement();
					Map< String, String > namespaces = definition.getNamespaces();
					for( Entry< String, String > entry : namespaces.entrySet() ) {
						if( entry.getKey().equals( "xmlns" ) || entry.getKey().trim().isEmpty() ) {
							continue;
						}
						if( schemaElement.getAttribute( "xmlns:" + entry.getKey() ).isEmpty() ) {
							schemaElement.setAttribute( "xmlns:" + entry.getKey(), entry.getValue() );
						}
					}
					parseSchemaElement( definition, schemaElement, schemaParser );
				}
			}
		}
	}
}
 
Example 5
Source Project: jolie   Source File: SoapProtocol.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
private void setOutputEncodingStyle( SOAPEnvelope soapEnvelope, String operationName )
	throws IOException, SOAPException {
	Port port = getWSDLPort();
	if( port != null ) {
		BindingOperation bindingOperation = port.getBinding().getBindingOperation( operationName, null, null );
		if( bindingOperation == null ) {
			return;
		}
		BindingOutput output = bindingOperation.getBindingOutput();
		if( output == null ) {
			return;
		}
		for( ExtensibilityElement element : (List< ExtensibilityElement >) output.getExtensibilityElements() ) {
			if( element instanceof javax.wsdl.extensions.soap.SOAPBody ) {
				List< String > list = ((javax.wsdl.extensions.soap.SOAPBody) element).getEncodingStyles();
				if( list != null && list.isEmpty() == false ) {
					soapEnvelope.setEncodingStyle( list.get( 0 ) );
					soapEnvelope.addNamespaceDeclaration( "enc", list.get( 0 ) );
				}
			}
		}
	}
}
 
Example 6
Source Project: carbon-apimgt   Source File: APIMWSDLReader.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Get the addressURl from the Extensibility element
 * @param exElement - {@link ExtensibilityElement}
 * @throws APIManagementException
 */
private void setAddressUrl(ExtensibilityElement exElement, String transports, API api) throws APIManagementException {

       if (exElement instanceof SOAP12AddressImpl) {
           ((SOAP12AddressImpl) exElement).setLocationURI(APIUtil.getGatewayendpoint(transports) + api.getContext());
       } else if (exElement instanceof SOAPAddressImpl) {
           ((SOAPAddressImpl) exElement).setLocationURI(APIUtil.getGatewayendpoint(transports) + api.getContext());
       } else if (exElement instanceof HTTPAddressImpl) {
           ((HTTPAddressImpl) exElement).setLocationURI(APIUtil.getGatewayendpoint(transports) + api.getContext());
       } else if (exElement instanceof UnknownExtensibilityElement) {
           Element unknownExtensibilityElement = ((UnknownExtensibilityElement) exElement).getElement();
           if (unknownExtensibilityElement != null) {
               NodeList nodeList = unknownExtensibilityElement.getElementsByTagNameNS(APIConstants.WSDL_NAMESPACE_URI,
                       APIConstants.WSDL_ELEMENT_LOCAL_NAME);
               if (nodeList != null && nodeList.getLength() > 0) {
                   nodeList.item(0).setTextContent(APIUtil.getGatewayendpoint(transports) + api.getContext());
               }
           }
       } else {
		String msg = "Unsupported WSDL errors!";
		log.error(msg);
		throw new APIManagementException(msg);
	}
}
 
Example 7
Source Project: cxf   Source File: MIMEBindingValidator.java    License: Apache License 2.0 6 votes vote down vote up
public boolean isValid() {
    Collection<Binding> bindings = CastUtils.cast(def.getBindings().values());
    for (Binding binding : bindings) {
        Collection<BindingOperation> bindingOps = CastUtils.cast(binding.getBindingOperations());
        for (BindingOperation bindingOperation : bindingOps) {
            if (bindingOperation.getBindingInput() == null) {
                continue;
            }
            Collection<ExtensibilityElement> exts = CastUtils.cast(bindingOperation
                                                                       .getBindingInput()
                                                                       .getExtensibilityElements());
            for (ExtensibilityElement extElement : exts) {
                if (extElement instanceof MIMEMultipartRelated
                    && !doValidate((MIMEMultipartRelated)extElement,
                                   bindingOperation.getName())) {
                    return false;
                }
            }
        }
    }
    return true;
}
 
Example 8
Source Project: cxf   Source File: AttributeVisitor.java    License: Apache License 2.0 6 votes vote down vote up
private BindingOperation generateCorbaBindingOperation(Binding wsdlBinding,
                                                       Operation op,
                                                       OperationType corbaOp) {
    BindingInput bindingInput = definition.createBindingInput();
    bindingInput.setName(op.getInput().getName());

    BindingOutput bindingOutput = definition.createBindingOutput();
    bindingOutput.setName(op.getOutput().getName());

    BindingOperation bindingOperation = definition.createBindingOperation();
    bindingOperation.addExtensibilityElement((ExtensibilityElement)corbaOp);
    bindingOperation.setOperation(op);
    bindingOperation.setName(op.getName());

    bindingOperation.setBindingInput(bindingInput);
    bindingOperation.setBindingOutput(bindingOutput);

    binding.addBindingOperation(bindingOperation);

    return bindingOperation;
}
 
Example 9
Source Project: cxf   Source File: ServiceWSDLBuilder.java    License: Apache License 2.0 6 votes vote down vote up
protected void addExtensibilityElements(Definition def,
                                        ElementExtensible elementExtensible,
                                        List<ExtensibilityElement> extensibilityElements) {
    if (extensibilityElements != null) {
        for (ExtensibilityElement element : extensibilityElements) {
            if (element instanceof UnknownExtensibilityElement) {
                UnknownExtensibilityElement uee = (UnknownExtensibilityElement)element;
                String pfx = uee.getElement().getPrefix();
                addNamespace(pfx, element.getElementType().getNamespaceURI(), def);
            } else {
                QName qn = element.getElementType();
                addNamespace(qn.getNamespaceURI(), def);
            }
            elementExtensible.addExtensibilityElement(element);
        }
    }
}
 
Example 10
Source Project: cxf   Source File: HeaderUtil.java    License: Apache License 2.0 6 votes vote down vote up
private static Set<QName> getHeaderQNames(BindingMessageInfo bmi) {
    Set<QName> set = new HashSet<>();
    List<MessagePartInfo> mps = bmi.getMessageInfo().getMessageParts();
    List<ExtensibilityElement> extList = bmi.getExtensors(ExtensibilityElement.class);
    if (extList != null) {
        for (ExtensibilityElement ext : extList) {
            if (SOAPBindingUtil.isSOAPHeader(ext)) {
                SoapHeader header = SOAPBindingUtil.getSoapHeader(ext);
                String pn = header.getPart();
                for (MessagePartInfo mpi : mps) {
                    if (pn.equals(mpi.getName().getLocalPart())) {
                        if (mpi.isElement()) {
                            set.add(mpi.getElementQName());
                        } else {
                            set.add(mpi.getTypeQName());
                        }
                        break;
                    }
                }
            }
        }
    }
    return set;
}
 
Example 11
Source Project: cxf   Source File: WSDLToCorbaBindingTest.java    License: Apache License 2.0 6 votes vote down vote up
private void checkFixedTypeThree(BindingOperation bindingOperation,
                                 Map<String, CorbaType>  mapType) {
    for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
        if ("operation".equals(extElement.getElementType().getLocalPart())) {
            OperationType corbaOpType = (OperationType)extElement;
            assertEquals(corbaOpType.getName(), "op_n");
            assertEquals(3, corbaOpType.getParam().size());
            assertEquals("fixed_1", corbaOpType.getParam().get(0).getIdltype().getLocalPart());
            assertEquals("Z.H", corbaOpType.getReturn().getIdltype().getLocalPart());
            Fixed fixed = (Fixed)mapType.get(corbaOpType.getReturn().getIdltype().getLocalPart());
            assertNotNull("Could not find the decimal type", fixed.getType());
            assertEquals("Fixed digits is incorrect for the return corba parameter", 8, fixed
                .getDigits());
            assertEquals("Fixed scale is incorrect for the return corba parameter", 6, fixed.getScale());

        }
    }
}
 
Example 12
Source Project: cxf   Source File: WSDLToCorbaBindingTest.java    License: Apache License 2.0 6 votes vote down vote up
private void checkFixedTypeFour(BindingOperation bindingOperation,
                                Map<String, CorbaType>  mapType) {
    for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
        if ("operation".equals(extElement.getElementType().getLocalPart())) {
            OperationType corbaOpType = (OperationType)extElement;
            assertEquals(corbaOpType.getName(), "extended_op_m");
            assertEquals(3, corbaOpType.getParam().size());
            assertEquals("EXTENDED.X.PARAM.H", corbaOpType.getParam().get(0).getIdltype().getLocalPart());
            assertEquals("EXTENDED.X.PARAM.H", corbaOpType.getReturn().getIdltype().getLocalPart());
            Fixed fixed = (Fixed)mapType.get(corbaOpType.getReturn().getIdltype().getLocalPart());
            assertNotNull("Could not find the decimal type", fixed.getType());
            assertEquals("Fixed digits is incorrect for the return corba parameter", 8, fixed
                .getDigits());
            assertEquals("Fixed scale is incorrect for the return corba parameter", 2, fixed.getScale());

        }
    }
}
 
Example 13
Source Project: cxf   Source File: WSDLToCorbaBindingTest.java    License: Apache License 2.0 6 votes vote down vote up
private void testPrimitiveTypeTest(Binding binding, String name, QName corbaType) {
    BindingOperation bindingOp = binding.getBindingOperation(name,
                                            name, name + "Response");
    assertEquals(name, bindingOp.getName());
    assertEquals(1, bindingOp.getExtensibilityElements().size());
    assertEquals(bindingOp.getBindingInput().getName(), name);
    assertEquals(bindingOp.getBindingOutput().getName(), name + "Response");
    for (ExtensibilityElement extElement : getExtensibilityElements(bindingOp)) {
        if ("operation".equals(extElement.getElementType().getLocalPart())) {
            OperationType corbaOpType = (OperationType)extElement;
            assertEquals(corbaOpType.getName(), name);
            assertEquals(3, corbaOpType.getParam().size());
            assertEquals(corbaOpType.getParam().get(0).getName(), "x");
            assertEquals(corbaOpType.getParam().get(0).getMode().value(), "in");
            assertEquals(corbaOpType.getParam().get(0).getIdltype(),
                         corbaType);
            assertEquals(corbaOpType.getReturn().getName(), "return");
            assertEquals(corbaOpType.getReturn().getIdltype(), corbaType);

        }
    }
}
 
Example 14
Source Project: cxf   Source File: JAXWSBindingDeserializer.java    License: Apache License 2.0 6 votes vote down vote up
public ExtensibilityElement unmarshall(@SuppressWarnings("rawtypes") Class parentType,
                                       QName elementType,
                                       Element el,
                                       Definition def,
                                       ExtensionRegistry extReg) throws WSDLException {
    JAXWSBinding jaxwsBinding = (JAXWSBinding)extReg.createExtension(parentType, elementType);

    jaxwsBinding.setElementType(elementType);
    jaxwsBinding.setElement(el);
    jaxwsBinding.setDocumentBaseURI(def.getDocumentBaseURI());

    JAXWSBindingParser parser = new JAXWSBindingParser(extReg);
    parser.parseElement(jaxwsBinding, el);

    return jaxwsBinding;
}
 
Example 15
Source Project: cxf   Source File: ServiceProcessor.java    License: Apache License 2.0 6 votes vote down vote up
private static String getJavaTypeForMimeType(MIMEPart mPart) {
    if (mPart.getExtensibilityElements().size() > 1) {
        return "javax.activation.DataHandler";
    }
    ExtensibilityElement extElement = (ExtensibilityElement)mPart.getExtensibilityElements().get(0);
    if (extElement instanceof MIMEContent) {
        MIMEContent mimeContent = (MIMEContent)extElement;
        if ("image/jpeg".equals(mimeContent.getType()) || "image/gif".equals(mimeContent.getType())) {
            return "java.awt.Image";
        } else if ("text/xml".equals(mimeContent.getType())
                   || "application/xml".equals(mimeContent.getType())) {
            return "javax.xml.transform.Source";
        }  else {
            return "javax.activation.DataHandler";
        }
    }
    return "javax.activation.DataHandler";
}
 
Example 16
Source Project: cxf   Source File: WSDLToServiceProcessor.java    License: Apache License 2.0 6 votes vote down vote up
private void setAddrElement() throws ToolException {
    String transport = (String)env.get(ToolConstants.CFG_TRANSPORT);
    Address address = AddressFactory.getInstance().getAddresser(transport);

    Map<String, String> ns = address.getNamespaces(env);
    for (Map.Entry<String, String> entry : ns.entrySet()) {
        wsdlDefinition.addNamespace(entry.getKey(), entry.getValue());
    }

    WSDLExtensibilityPlugin plugin = getWSDLPlugin(transport, Port.class);
    try {
        ExtensibilityElement extElement = plugin.createExtension(address.buildAddressArguments(env));
        port.addExtensibilityElement(extElement);
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_CREATE_SOAP_ADDRESS", LOG);
        throw new ToolException(msg, wse);
    }
}
 
Example 17
Source Project: cxf   Source File: SoapBindingFactory.java    License: Apache License 2.0 6 votes vote down vote up
private void initializeBindingOperation(SoapBindingInfo bi, BindingOperationInfo boi) {
    SoapOperationInfo soi = new SoapOperationInfo();

    SoapOperation soapOp =
        SOAPBindingUtil.getSoapOperation(boi.getExtensors(ExtensibilityElement.class));

    if (soapOp != null) {
        String action = soapOp.getSoapActionURI();
        if (action == null) {
            action = "";
        }
        soi.setAction(action);
        soi.setStyle(soapOp.getStyle());
    }

    boi.addExtensor(soi);

    if (boi.getInput() != null) {
        initializeMessage(bi, boi, boi.getInput());
    }

    if (boi.getOutput() != null) {
        initializeMessage(bi, boi, boi.getOutput());
    }
}
 
Example 18
Source Project: cxf   Source File: Wsdl11AttachmentPolicyProvider.java    License: Apache License 2.0 6 votes vote down vote up
private Extensible getMessageTypeInfo(QName name, DescriptionInfo di) {
    if (null == di) {
        return null;
    }
    Definition def = (Definition)di.getProperty("org.apache.cxf.wsdl11.WSDLServiceBuilder.DEFINITION");
    if (null == def) {
        return null;
    }

    javax.wsdl.Message m = def.getMessage(name);
    if (null != m) {
        List<ExtensibilityElement> extensors =
            CastUtils.cast(m.getExtensibilityElements(), ExtensibilityElement.class);
        if (null != extensors) {
            return new ExtensibleInfo(extensors);
        }
    }
    return null;
}
 
Example 19
Source Project: cxf   Source File: SOAPBindingUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static SoapFault createSoapFault(ExtensionRegistry extReg, boolean isSOAP12)
    throws WSDLException {
    ExtensibilityElement extElement = null;
    if (isSOAP12) {
        extElement = extReg.createExtension(BindingFault.class,
                                                         new QName(WSDLConstants.NS_SOAP12,
                                                                   "fault"));
    } else {
        extElement = extReg.createExtension(BindingFault.class,
                                                       new QName(WSDLConstants.NS_SOAP11,
                                                                 "fault"));
    }
    return getSoapFault(extElement);
}
 
Example 20
Source Project: hop   Source File: WsdlComplexTypes.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create a new instance, parse the WSDL file for named complex types.
 *
 * @param wsdlTypes Name space resolver.
 */
protected WsdlComplexTypes( WsdlTypes wsdlTypes ) {

  List<ExtensibilityElement> schemas = wsdlTypes.getSchemas();
  for ( ExtensibilityElement schema : schemas ) {
    Element schemaRoot = ( (Schema) schema ).getElement();

    List<Element> types = DomUtils.getChildElementsByName( schemaRoot, WsdlUtils.COMPLEX_TYPE_NAME );
    for ( Element t : types ) {
      String schemaTypeName = t.getAttribute( WsdlUtils.NAME_ATTR );
      _complexTypes.put( schemaTypeName, new ComplexType( t, wsdlTypes ) );
    }
  }
}
 
Example 21
Source Project: hop   Source File: WsdlUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get the SOAP address location for the specified port.
 *
 * @param p A WSDL Port instance.
 * @return The SOAP address URI.
 */
protected static String getSOAPAddress( Port p ) {
  ExtensibilityElement e = findExtensibilityElement( (ElementExtensible) p, SOAP_PORT_ADDRESS_NAME );
  if ( e instanceof SOAP12Address ) {
    return ( (SOAP12Address) e ).getLocationURI();
  } else if ( e instanceof SOAPAddress ) {
    return ( (SOAPAddress) e ).getLocationURI();
  }

  return null;
}
 
Example 22
Source Project: cxf   Source File: SchemaSerializer.java    License: Apache License 2.0 5 votes vote down vote up
public void marshall(@SuppressWarnings("rawtypes") Class parentType,
                     QName elementType, ExtensibilityElement extension, PrintWriter pw,
                     Definition def, ExtensionRegistry extReg) throws WSDLException {
    try {
        writeXml(((Schema)extension).getElement(), pw);
    } catch (XMLStreamException e) {
        throw new WSDLException("", "Could not write schema.", e);
    }
}
 
Example 23
Source Project: hop   Source File: WsdlUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get the Soap Action URI from the operation's soap:operation extensiblity element.
 *
 * @param operation A WSDL Operation.
 * @return Soap action URI as string, null if not defined.
 */
protected static String getSOAPAction( BindingOperation operation ) {
  ExtensibilityElement e = findExtensibilityElement( (ElementExtensible) operation, SOAP_OPERATION_ELEMENT_NAME );
  if ( e != null ) {
    if ( e instanceof SOAP12Operation ) {
      return ( (SOAP12Operation) e ).getSoapActionURI();
    } else {
      return ( (SOAPOperation) e ).getSoapActionURI();
    }
  }
  return null;
}
 
Example 24
Source Project: hop   Source File: WsdlUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Build a HashSet of SOAP header names for the specified operation and binding.
 *
 * @param binding       WSDL Binding instance.
 * @param operationName Name of the operation.
 * @return HashSet of soap header names, empty set if no headers present.
 */
protected static HashSet<String> getSOAPHeaders( Binding binding, String operationName ) {

  List<ExtensibilityElement> headers = new ArrayList<ExtensibilityElement>();
  BindingOperation bindingOperation = binding.getBindingOperation( operationName, null, null );
  if ( bindingOperation == null ) {
    throw new IllegalArgumentException( "Can not find operation: " + operationName );
  }

  BindingInput bindingInput = bindingOperation.getBindingInput();
  if ( bindingInput != null ) {
    headers.addAll( WsdlUtils.findExtensibilityElements( (ElementExtensible) bindingInput, SOAP_HEADER_ELEMENT_NAME ) );
  }

  BindingOutput bindingOutput = bindingOperation.getBindingOutput();
  if ( bindingOutput != null ) {
    headers.addAll( WsdlUtils.findExtensibilityElements( (ElementExtensible) bindingOutput, SOAP_HEADER_ELEMENT_NAME ) );
  }

  HashSet<String> headerSet = new HashSet<String>( headers.size() );
  for ( ExtensibilityElement element : headers ) {
    if ( element instanceof SOAP12Header ) {
      headerSet.add( ( (SOAP12Header) element ).getPart() );
    } else {
      headerSet.add( ( (SOAPHeader) element ).getPart() );
    }
  }

  return headerSet;
}
 
Example 25
Source Project: hop   Source File: WsdlUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Find the specified extensibility element, if more than one with the specified name exists in the list, return the
 * first one found.
 *
 * @param extensibleElement WSDL type which extends ElementExtensible.
 * @param elementType       Name of the extensiblity element to find.
 * @return ExtensibilityElement The ExtensiblityElement, if not found return null.
 */
@SuppressWarnings( "unchecked" )
protected static ExtensibilityElement findExtensibilityElement( ElementExtensible extensibleElement,
                                                                String elementType ) {

  List<ExtensibilityElement> extensibilityElements = extensibleElement.getExtensibilityElements();
  if ( extensibilityElements != null ) {
    for ( ExtensibilityElement element : extensibilityElements ) {
      if ( element.getElementType().getLocalPart().equalsIgnoreCase( elementType ) ) {
        return element;
      }
    }
  }
  return null;
}
 
Example 26
Source Project: cxf   Source File: ServiceWSDLBuilderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemas() throws Exception {
    setupWSDL(WSDL_PATH);
    Types types = newDef.getTypes();
    assertNotNull(types);
    Collection<ExtensibilityElement> schemas =
        CastUtils.cast(types.getExtensibilityElements(), ExtensibilityElement.class);
    assertEquals(1, schemas.size());
    XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
    Element schemaElem = ((Schema)schemas.iterator().next()).getElement();
    XmlSchema newSchema = schemaCollection.read(schemaElem);
    assertEquals("http://apache.org/hello_world_soap_http/types",
                 newSchema.getTargetNamespace()
                 );
}
 
Example 27
Source Project: Tomcat7.0.67   Source File: ServiceRefFactory.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param port analyzed port
 * @return Returns the endpoint URL of the given Port
 */
private String getSOAPLocation(Port port) {
    String endpoint = null;
    @SuppressWarnings("unchecked") // Can't change the API
    List<ExtensibilityElement> extensions = port.getExtensibilityElements();
    for (Iterator<ExtensibilityElement> i = extensions.iterator();
            i.hasNext();) {
        ExtensibilityElement ext = i.next();
        if (ext instanceof SOAPAddress) {
            SOAPAddress addr = (SOAPAddress) ext;
            endpoint = addr.getLocationURI();
        }
    }
    return endpoint;
}
 
Example 28
Source Project: tomcatsrc   Source File: ServiceRefFactory.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param port analyzed port
 * @return Returns the endpoint URL of the given Port
 */
private String getSOAPLocation(Port port) {
    String endpoint = null;
    @SuppressWarnings("unchecked") // Can't change the API
    List<ExtensibilityElement> extensions = port.getExtensibilityElements();
    for (Iterator<ExtensibilityElement> i = extensions.iterator();
            i.hasNext();) {
        ExtensibilityElement ext = i.next();
        if (ext instanceof SOAPAddress) {
            SOAPAddress addr = (SOAPAddress) ext;
            endpoint = addr.getLocationURI();
        }
    }
    return endpoint;
}
 
Example 29
Source Project: pentaho-kettle   Source File: WsdlUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get the Soap Action URI from the operation's soap:operation extensiblity element.
 *
 * @param operation
 *          A WSDL Operation.
 * @return Soap action URI as string, null if not defined.
 */
protected static String getSOAPAction( BindingOperation operation ) {
  ExtensibilityElement e = findExtensibilityElement( operation, SOAP_OPERATION_ELEMENT_NAME );
  if ( e != null ) {
    if ( e instanceof SOAP12Operation ) {
      return ( (SOAP12Operation) e ).getSoapActionURI();
    } else {
      return ( (SOAPOperation) e ).getSoapActionURI();
    }
  }
  return null;
}
 
Example 30
Source Project: jolie   Source File: SoapProtocol.java    License: 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;
}