javax.wsdl.extensions.ExtensionRegistry Java Examples

The following examples show how to use javax.wsdl.extensions.ExtensionRegistry. 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: XTeeSoapProvider.java    From j-road with Apache License 2.0 6 votes vote down vote up
private List<SOAPHeader> makeHeaders(Definition definition) throws WSDLException {
  List<SOAPHeader> list = new ArrayList<SOAPHeader>();
  String[] parts = new String[] { XTeeHeader.CLIENT.getLocalPart(), XTeeHeader.SERVICE.getLocalPart(),
                                  XTeeHeader.USER_ID.getLocalPart(), XTeeHeader.ID.getLocalPart(),
                                  XTeeHeader.PROTOCOL_VERSION.getLocalPart() };
  ExtensionRegistry extReg = definition.getExtensionRegistry();
  for (int i = 0; i < parts.length; i++) {
    SOAPHeader header =
        (SOAPHeader) extReg.createExtension(BindingInput.class, new QName(SOAP_11_NAMESPACE_URI, "header"));
    header.setMessage(new QName(definition.getTargetNamespace(), XTeeWsdlDefinition.XROAD_HEADER));
    header.setPart(parts[i]);
    if (use.equalsIgnoreCase(LITERAL)) {
      header.setUse(LITERAL);
    } else {
      header.setUse(ENCODED);
      header.setEncodingStyles(Arrays.asList(ENCODING));
    }
    list.add(header);
  }

  return list;
}
 
Example #2
Source File: XTeeSoapProvider.java    From j-road with Apache License 2.0 6 votes vote down vote up
@Override
protected void populatePort(Definition definition, Port port) throws WSDLException {
  super.populatePort(definition, port);
  ExtensionRegistry extensionRegistry = definition.getExtensionRegistry();
  extensionRegistry.mapExtensionTypes(Port.class,
                                      new QName(XTeeWsdlDefinition.XROAD_NAMESPACE,
                                                "address",
                                                XTeeWsdlDefinition.XROAD_PREFIX),
                                      UnknownExtensibilityElement.class);
  UnknownExtensibilityElement element =
      (UnknownExtensibilityElement) extensionRegistry.createExtension(Port.class,
                                                                      new QName(XTeeWsdlDefinition.XROAD_NAMESPACE,
                                                                                "address",
                                                                                XTeeWsdlDefinition.XROAD_NAMESPACE));
  Document doc;
  try {
    doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
  } catch (ParserConfigurationException e) {
    throw new RuntimeException(e);
  }
  Element xRoadAddr = doc.createElementNS(XTeeWsdlDefinition.XROAD_NAMESPACE, "address");
  xRoadAddr.setPrefix(XTeeWsdlDefinition.XROAD_PREFIX);
  xRoadAddr.setAttribute("producer", xRoadDatabase);
  element.setElement(xRoadAddr);
  port.addExtensibilityElement(element);
}
 
Example #3
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static SOAPBinding createSoapBinding(ExtensionRegistry extReg, boolean isSOAP12)
    throws WSDLException {
    ExtensibilityElement extElement = null;
    if (isSOAP12) {
        extElement = extReg.createExtension(Binding.class,
                                                           new QName(WSDLConstants.NS_SOAP12,
                                                                     "binding"));
        ((SOAP12Binding)extElement).setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
    } else {
        extElement = extReg.createExtension(Binding.class,
                                                         new QName(WSDLConstants.NS_SOAP11,
                                                                   "binding"));
        ((SOAPBinding)extElement).setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
    }
    return getSoapBinding(extElement);
}
 
Example #4
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static SoapBinding createSoapBinding(ExtensionRegistry extReg, boolean isSOAP12)
    throws WSDLException {
    ExtensibilityElement extElement = null;
    if (isSOAP12) {
        extElement = extReg.createExtension(Binding.class,
                                                           new QName(WSDLConstants.NS_SOAP12,
                                                                     "binding"));
        ((SOAP12Binding)extElement).setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
    } else {
        extElement = extReg.createExtension(Binding.class,
                                                         new QName(WSDLConstants.NS_SOAP11,
                                                                   "binding"));
        ((SOAPBinding)extElement).setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
    }
    return getSoapBinding(extElement);
}
 
Example #5
Source File: SoapTransportFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void createSoapExtensors(Bus bus, EndpointInfo ei, SoapBindingInfo bi, boolean isSoap12) {
    try {

        String address = ei.getAddress();
        if (address == null) {
            address = "http://localhost:9090";
        }

        ExtensionRegistry registry = bus.getExtension(WSDLManager.class).getExtensionRegistry();
        SoapAddress soapAddress = SOAPBindingUtil.createSoapAddress(registry, isSoap12);
        soapAddress.setLocationURI(address);

        ei.addExtensor(soapAddress);

    } catch (WSDLException e) {
        e.printStackTrace();
    }
}
 
Example #6
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private static void addBindingOperation(Definition wsdlDefinition, PortType portType, Binding binding,
                                        ExtensionRegistry extReg) throws Exception {
    List<Operation> ops = portType.getOperations();
    for (Operation op : ops) {
        BindingOperation bindingOperation = wsdlDefinition.createBindingOperation();
        setSoapOperationExtElement(bindingOperation, extReg);
        bindingOperation.setName(op.getName());
        if (op.getInput() != null) {
            bindingOperation.setBindingInput(getBindingInput(op.getInput(), wsdlDefinition, extReg));
        }
        if (op.getOutput() != null) {
            bindingOperation.setBindingOutput(getBindingOutput(op.getOutput(), wsdlDefinition, extReg));
        }
        if (op.getFaults() != null && op.getFaults().size() > 0) {
            addSoapFaults(op, bindingOperation, wsdlDefinition, extReg);
        }
        bindingOperation.setOperation(op);
        binding.addBindingOperation(bindingOperation);
    }
}
 
Example #7
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 #8
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static SOAPAddress createSoapAddress(ExtensionRegistry extReg, boolean isSOAP12)
    throws WSDLException {
    ExtensibilityElement extElement = null;
    if (isSOAP12) {
        extElement = extReg.createExtension(Port.class,
                                                           WSDLConstants.QNAME_SOAP12_BINDING_ADDRESS);
    } else {
        extElement = extReg.createExtension(Port.class,
                                                         WSDLConstants.QNAME_SOAP_BINDING_ADDRESS);
    }
    return getSoapAddress(extElement);
}
 
Example #9
Source File: Wsdl.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Get a WSDLReader.
 *
 * @return WSDLReader.
 * @throws WSDLException
 *           on error.
 */
private WSDLReader getReader() throws WSDLException {

  WSDLFactory wsdlFactory = WSDLFactory.newInstance();
  WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
  ExtensionRegistry registry = wsdlFactory.newPopulatedExtensionRegistry();
  wsdlReader.setExtensionRegistry( registry );
  wsdlReader.setFeature( "javax.wsdl.verbose", true );
  wsdlReader.setFeature( "javax.wsdl.importDocuments", true );
  return wsdlReader;
}
 
Example #10
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static SOAPBody createSoapBody(ExtensionRegistry extReg, Class<?> clz, boolean isSOAP12)
    throws WSDLException {
    ExtensibilityElement extElement = null;
    if (isSOAP12) {
        extElement = extReg.createExtension(clz, new QName(WSDLConstants.NS_SOAP12,
                                                                       "body"));
    } else {
        extElement = extReg.createExtension(clz, new QName(WSDLConstants.NS_SOAP11,
                                                                     "body"));
    }
    return getSoapBody(extElement);
}
 
Example #11
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static SOAPOperation createSoapOperation(ExtensionRegistry extReg, boolean isSOAP12)
    throws WSDLException {
    ExtensibilityElement extElement = null;
    if (isSOAP12) {
        extElement = extReg.createExtension(BindingOperation.class,
                                                             new QName(WSDLConstants.NS_SOAP12,
                                                                       "operation"));
    } else {
        extElement = extReg.createExtension(BindingOperation.class,
                                                           new QName(WSDLConstants.NS_SOAP11,
                                                                     "operation"));
    }
    return getSoapOperation(extElement);
}
 
Example #12
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 #13
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 #14
Source File: WSDLManagerImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void addExtensionAttributeTypes(ExtensionRegistry extreg) {
    // register types that are not of wsdl4j's default attribute type QName
    QName qn = new QName("http://www.w3.org/2006/05/addressing/wsdl", "Action");
    extreg.registerExtensionAttributeType(javax.wsdl.Input.class, qn, AttributeExtensible.STRING_TYPE);
    extreg.registerExtensionAttributeType(javax.wsdl.Output.class, qn, AttributeExtensible.STRING_TYPE);
    extreg.registerExtensionAttributeType(javax.wsdl.Fault.class, qn, AttributeExtensible.STRING_TYPE);
    qn = new QName("http://www.w3.org/2007/05/addressing/metadata", "Action");
    extreg.registerExtensionAttributeType(javax.wsdl.Input.class, qn, AttributeExtensible.STRING_TYPE);
    extreg.registerExtensionAttributeType(javax.wsdl.Output.class, qn, AttributeExtensible.STRING_TYPE);
    extreg.registerExtensionAttributeType(javax.wsdl.Fault.class, qn, AttributeExtensible.STRING_TYPE);
    qn = new QName("http://www.w3.org/2005/02/addressing/wsdl", "Action");
    extreg.registerExtensionAttributeType(javax.wsdl.Input.class, qn, AttributeExtensible.STRING_TYPE);
    extreg.registerExtensionAttributeType(javax.wsdl.Output.class, qn, AttributeExtensible.STRING_TYPE);
    extreg.registerExtensionAttributeType(javax.wsdl.Fault.class, qn, AttributeExtensible.STRING_TYPE);
}
 
Example #15
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static Binding doAppendBinding(Definition wsdlDefinition, String name, PortType portType,
                                         ExtensionRegistry extReg) throws Exception {
    Binding binding = wsdlDefinition.createBinding();
    binding.setQName(new QName(wsdlDefinition.getTargetNamespace(), name + bindingName));
    binding.setUndefined(false);
    binding.setPortType(portType);
    setSoapBindingExtElement(wsdlDefinition, binding, extReg);
    addBindingOperation(wsdlDefinition, portType, binding, extReg);
    return binding;


}
 
Example #16
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static void setSoapBindingExtElement(Definition wsdlDefinition, Binding binding,
                                             ExtensionRegistry extReg) throws Exception {
    SOAPBindingUtil.addSOAPNamespace(wsdlDefinition, false);
    SOAPBinding
        soapBinding = SOAPBindingUtil.createSoapBinding(extReg, false);
    soapBinding.setStyle(style);
    binding.addExtensibilityElement(soapBinding);
}
 
Example #17
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static BindingInput getBindingInput(Input input, Definition wsdlDefinition,
                                            ExtensionRegistry extReg) throws Exception {
    BindingInput bi = wsdlDefinition.createBindingInput();
    bi.setName(input.getName());
    bi.addExtensibilityElement(getSoapBody(BindingInput.class, extReg));
    return bi;
}
 
Example #18
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static BindingOutput getBindingOutput(Output output, Definition wsdlDefinition,
                                              ExtensionRegistry extReg) throws Exception {
    BindingOutput bo = wsdlDefinition.createBindingOutput();
    bo.setName(output.getName());
    bo.addExtensibilityElement(getSoapBody(BindingOutput.class, extReg));
    return bo;
}
 
Example #19
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static void addSoapFaults(Operation op, BindingOperation bindingOperation, Definition wsdlDefinition,
                                  ExtensionRegistry extReg) throws Exception {
    Map<String, Fault> faults = CastUtils.cast(op.getFaults());
    for (Fault fault : faults.values()) {
        BindingFault bf = wsdlDefinition.createBindingFault();
        bf.setName(fault.getName());
        setSoapFaultExtElement(bf, extReg);
        bindingOperation.addBindingFault(bf);
    }
}
 
Example #20
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static javax.wsdl.Service doAppendService(Definition wsdlDefinition,
                                                 String existPortName, ExtensionRegistry
                                                 extReg, Binding binding) throws Exception {
    javax.wsdl.Service wsdlService = wsdlDefinition.createService();
    wsdlService.setQName(new QName(wsdlDefinition.getTargetNamespace(), existPortName + serviceName));
    Port port = wsdlDefinition.createPort();
    port.setName(existPortName + portName);
    port.setBinding(binding);
    SOAPAddress address = PartialWSDLProcessor.setAddrElement(wsdlDefinition, port, extReg);
    port.addExtensibilityElement(address);
    wsdlService.addPort(port);
    return wsdlService;
}
 
Example #21
Source File: SchemaSerializer.java    From cxf with 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 #22
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)
    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, null);
}
 
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: Wsdl.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * Get a WSDLReader.
 *
 * @return WSDLReader.
 * @throws WSDLException on error.
 */
private WSDLReader getReader() throws WSDLException {

  WSDLFactory wsdlFactory = WSDLFactory.newInstance();
  WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
  ExtensionRegistry registry = wsdlFactory.newPopulatedExtensionRegistry();
  wsdlReader.setExtensionRegistry( registry );
  wsdlReader.setFeature( "javax.wsdl.verbose", true );
  wsdlReader.setFeature( "javax.wsdl.importDocuments", true );
  return wsdlReader;
}
 
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: XTeeElement.java    From j-road with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "rawtypes" })
public void marshall(Class parentType,
                     QName elementType,
                     ExtensibilityElement extension,
                     PrintWriter pw,
                     Definition def,
                     ExtensionRegistry extReg) throws WSDLException {
  pw.append("        <" + XTeeWsdlDefinition.XROAD_PREFIX + ":" + elementType.getLocalPart() + ">");
  pw.append(((XTeeElement) extension).getValue());
  pw.append("</" + XTeeWsdlDefinition.XROAD_PREFIX + ":" + elementType.getLocalPart() + ">\n");
}
 
Example #27
Source File: SchemaFactoryImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new instance of a Definition, with an instance of a
 * PopulatedExtensionRegistry as its ExtensionRegistry.
 *
 */
public Definition newDefinition() {
    Definition def = factory.newDefinition();
    ExtensionRegistry extReg = newPopulatedExtensionRegistry();

    def.setExtensionRegistry(extReg);

    return def;
}
 
Example #28
Source File: WSDLCorbaFactoryImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new instance of a Definition, with an instance of a
 * PopulatedExtensionRegistry as its ExtensionRegistry.
 */
public Definition newDefinition() {
    Definition def = factory.newDefinition();
    ExtensionRegistry extReg = newPopulatedExtensionRegistry();
    def.setExtensionRegistry(extReg);
    return def;
}
 
Example #29
Source File: JAXWSBindingSerializer.java    From cxf with 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 {
    // This class is needed to generate the WSDL file included in the client jar. 
    // It simply ignores the JAXWS Binding when generating the WSDL file. 
}
 
Example #30
Source File: JAXWSDefinitionBuilder.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void registerJaxwsExtension(ExtensionRegistry registry) {
    registerJAXWSBinding(registry, Definition.class);
    registerJAXWSBinding(registry, Service.class);
    registerJAXWSBinding(registry, Fault.class);
    registerJAXWSBinding(registry, PortType.class);
    registerJAXWSBinding(registry, Port.class);
    registerJAXWSBinding(registry, Operation.class);
    registerJAXWSBinding(registry, Binding.class);
    registerJAXWSBinding(registry, BindingOperation.class);
}