javax.wsdl.extensions.ExtensibilityElement Java Examples

The following examples show how to use javax.wsdl.extensions.ExtensibilityElement. 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: ServiceWSDLBuilder.java    From cxf with 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 #2
Source File: Wsdl11AttachmentPolicyProvider.java    From cxf with 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 #3
Source File: SoapBindingFactory.java    From cxf with 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 #4
Source File: WsdlTypes.java    From hop with 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 #5
Source File: WsdlTypes.java    From hop with 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 #6
Source File: RMEndpointTest.java    From cxf with 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 #7
Source File: SoapProtocol.java    From jolie with 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 #8
Source File: WSDLToServiceProcessor.java    From cxf with 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 #9
Source File: SoapProtocol.java    From jolie with 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 #10
Source File: ServiceProcessor.java    From cxf with 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 #11
Source File: JAXWSBindingDeserializer.java    From cxf with 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 #12
Source File: APIMWSDLReader.java    From carbon-apimgt with 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 #13
Source File: WSDLToCorbaBindingTest.java    From cxf with 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 File: MIMEBindingValidator.java    From cxf with 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 #15
Source File: WSDLToCorbaBindingTest.java    From cxf with 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 #16
Source File: WSDLToCorbaBindingTest.java    From cxf with 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 #17
Source File: AttributeVisitor.java    From cxf with 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 #18
Source File: HeaderUtil.java    From cxf with 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 #19
Source File: WSDLToXMLProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private ExtensibilityElement getXMLBody(Class<?> clz, String operationName) throws ToolException {
    if (extReg == null) {
        extReg = wsdlFactory.newPopulatedExtensionRegistry();
    }
    Map<String, Object> args = new HashMap<>();
    args.put(QName.class.getName(), new QName(wsdlDefinition.getTargetNamespace(), operationName));
    args.put(Class.class.getName(), clz);

    try {
        return getWSDLPlugin("xml", clz).createExtension(args);
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_CREATE_XMLBINDING", LOG);
        throw new ToolException(msg);
    }
}
 
Example #20
Source File: WsdlUtils.java    From pentaho-kettle with 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( bindingInput, SOAP_HEADER_ELEMENT_NAME ) );
  }

  BindingOutput bindingOutput = bindingOperation.getBindingOutput();
  if ( bindingOutput != null ) {
    headers.addAll( WsdlUtils.findExtensibilityElements( 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 #21
Source File: MAPAggregatorImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * @param exts list of extension elements
 * @return true iff the UsingAddressing element is found
 */
private boolean hasUsingAddressing(List<ExtensibilityElement> exts) {
    boolean found = false;
    if (exts != null) {
        Iterator<ExtensibilityElement> extensionElements = exts.iterator();
        while (extensionElements.hasNext() && !found) {
            ExtensibilityElement ext =
                extensionElements.next();
            found = Names.WSAW_USING_ADDRESSING_QNAME.equals(ext.getElementType());
        }
    }
    return found;
}
 
Example #22
Source File: XmlIoPlugin.java    From cxf with Apache License 2.0 5 votes vote down vote up
public ExtensibilityElement createExtension(final Map<String, Object> args) throws WSDLException {
    XMLBindingMessageFormat xmlFormat = null;

    Class<?> clz = getOption(args, Class.class);
    QName qname = getOption(args, QName.class);

    ExtensibilityElement ext = registry.createExtension(clz, ToolConstants.XML_FORMAT);
    if (ext instanceof JAXBExtensibilityElement) {
        xmlFormat = (XMLBindingMessageFormat)((JAXBExtensibilityElement)ext).getValue();
    } else {
        xmlFormat = (XMLBindingMessageFormat)ext;
    }
    xmlFormat.setRootNode(qname);
    return ext;
}
 
Example #23
Source File: JAXBExtensionHelper.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static void addExtensions(ExtensionRegistry registry,
                                 String parentType,
                                 String elementType,
                                 String namespace)
    throws JAXBException, ClassNotFoundException {
    Class<?> parentTypeClass = ClassLoaderUtils.loadClass(parentType, JAXBExtensionHelper.class);

    Class<? extends ExtensibilityElement> elementTypeClass =
        ClassLoaderUtils.loadClass(elementType, JAXBExtensionHelper.class)
            .asSubclass(ExtensibilityElement.class);
    addExtensions(registry, parentTypeClass, elementTypeClass, namespace);
}
 
Example #24
Source File: MAPAggregatorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void setUpUsingAddressing(Message message,
                                  Exchange exchange,
                                  boolean usingAddressing) {
    setUpMessageExchange(message, exchange);
    Endpoint endpoint = control.createMock(Endpoint.class);
    endpoint.getOutInterceptors();
    EasyMock.expectLastCall().andReturn(new ArrayList<Interceptor<? extends Message>>()).anyTimes();

    setUpExchangeGet(exchange, Endpoint.class, endpoint);
    EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
    endpoint.getEndpointInfo();
    EasyMock.expectLastCall().andReturn(endpointInfo).anyTimes();
    List<ExtensibilityElement> endpointExts =
        new ArrayList<>();
    endpointInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
    EasyMock.expectLastCall().andReturn(endpointExts).anyTimes();
    BindingInfo bindingInfo = control.createMock(BindingInfo.class);
    endpointInfo.getBinding();
    EasyMock.expectLastCall().andReturn(bindingInfo).anyTimes();
    bindingInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
    EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST).anyTimes();
    ServiceInfo serviceInfo = control.createMock(ServiceInfo.class);
    endpointInfo.getService();
    EasyMock.expectLastCall().andReturn(serviceInfo).anyTimes();
    serviceInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
    EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST).anyTimes();
    ExtensibilityElement ext =
        control.createMock(ExtensibilityElement.class);
    if (usingAddressing) {
        QName elementType = usingAddressing
            ? Names.WSAW_USING_ADDRESSING_QNAME
            : new QName(SOAP_NAMESPACE, "encodingStyle");
        ext.getElementType();
        EasyMock.expectLastCall().andReturn(elementType).anyTimes();
        endpointExts.add(ext);
    }
}
 
Example #25
Source File: SOAPBindingUtil.java    From cxf with 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 #26
Source File: WSDLServiceBuilder.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void copyExtensors(AbstractPropertiesHolder info, List<?> extList) {
    if (info != null) {
        for (ExtensibilityElement ext : cast(extList, ExtensibilityElement.class)) {
            Object o = ext;
            if (ext instanceof JAXBExtensibilityElement) {
                o = ((JAXBExtensibilityElement)ext).getValue();
            }
            if (!info.containsExtensor(o)) {
                info.addExtensor(o);
            }
        }
    }
}
 
Example #27
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static SOAPHeader createSoapHeader(ExtensionRegistry extReg, Class<?> clz, boolean isSOAP12)
    throws WSDLException {
    ExtensibilityElement extElement = null;
    if (isSOAP12) {
        extElement = extReg.createExtension(clz,
                                                          new QName(WSDLConstants.NS_SOAP12,
                                                                    "header"));
    } else {
        extElement = extReg.createExtension(clz,
                                                        new QName(WSDLConstants.NS_SOAP11,
                                                                  "header"));
    }
    return getSoapHeader(extElement);
}
 
Example #28
Source File: WsdlUtils.java    From pentaho-kettle with 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 #29
Source File: WSDLCorbaWriterImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void fixTypes(Definition wsdlDef) throws ParserConfigurationException {
    Types t = wsdlDef.getTypes();
    if (t == null) {
        return;
    }
    List<ExtensibilityElement> l = CastUtils.cast(t.getExtensibilityElements());
    if (l == null) {
        return;
    }

    for (ExtensibilityElement e : l) {
        if (e instanceof Schema) {
            Schema sc = (Schema)e;
            String pfx = wsdlDef.getPrefix(sc.getElementType().getNamespaceURI());
            if (StringUtils.isEmpty(pfx)) {
                pfx = "xsd";
                String ns = wsdlDef.getNamespace(pfx);
                int count = 1;
                while (!StringUtils.isEmpty(ns)) {
                    pfx = "xsd" + count++;
                    ns = wsdlDef.getNamespace(pfx);
                }
                wsdlDef.addNamespace(pfx, sc.getElementType().getNamespaceURI());
            }
            if (sc.getElement() == null) {
                fixSchema(sc, pfx);
            }
        }
    }
}
 
Example #30
Source File: WSDLToCorbaBindingTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void testVoidTest(Binding binding) {
    BindingOperation bindingOp = binding.getBindingOperation("test_void",
                                            "test_void", "test_voidResponse");
    assertEquals("test_void", bindingOp.getName());
    assertEquals(1, bindingOp.getExtensibilityElements().size());
    assertEquals(bindingOp.getBindingInput().getName(), "test_void");
    assertEquals(bindingOp.getBindingOutput().getName(), "test_voidResponse");
    for (ExtensibilityElement extElement : getExtensibilityElements(bindingOp)) {
        if ("operation".equals(extElement.getElementType().getLocalPart())) {
            OperationType corbaOpType = (OperationType)extElement;
            assertEquals(corbaOpType.getName(), "test_void");
            assertEquals(0, corbaOpType.getParam().size());
        }
    }
}