Search in sources :

Example 6 with WSDLWriter

use of javax.wsdl.xml.WSDLWriter in project cxf by apache.

the class WSDLToServiceProcessor method doAppendService.

private void doAppendService() throws ToolException {
    if (service == null) {
        service = wsdlDefinition.createService();
        service.setQName(new QName(WSDLConstants.WSDL_PREFIX, (String) env.get(ToolConstants.CFG_SERVICE)));
    }
    if (port == null) {
        port = wsdlDefinition.createPort();
        port.setName((String) env.get(ToolConstants.CFG_PORT));
        port.setBinding(binding);
    }
    setAddrElement();
    service.addPort(port);
    wsdlDefinition.addService(service);
    WSDLWriter wsdlWriter = wsdlFactory.newWSDLWriter();
    Writer outputWriter = getOutputWriter(NEW_FILE_NAME_MODIFIER);
    try {
        wsdlWriter.writeWSDL(wsdlDefinition, outputWriter);
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_WRITE_WSDL", LOG);
        throw new ToolException(msg, wse);
    }
    try {
        outputWriter.close();
    } catch (IOException ioe) {
        Message msg = new Message("FAIL_TO_CLOSE_WSDL_FILE", LOG);
        throw new ToolException(msg, ioe);
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) WSDLException(javax.wsdl.WSDLException) QName(javax.xml.namespace.QName) WSDLWriter(javax.wsdl.xml.WSDLWriter) ToolException(org.apache.cxf.tools.common.ToolException) IOException(java.io.IOException) Writer(java.io.Writer) WSDLWriter(javax.wsdl.xml.WSDLWriter)

Example 7 with WSDLWriter

use of javax.wsdl.xml.WSDLWriter in project cxf by apache.

the class WSDLToSoapProcessor method doAppendBinding.

private void doAppendBinding() throws ToolException {
    if (binding == null) {
        binding = wsdlDefinition.createBinding();
        binding.setQName(new QName(wsdlDefinition.getTargetNamespace(), (String) env.get(ToolConstants.CFG_BINDING)));
        binding.setUndefined(false);
        binding.setPortType(portType);
    }
    setSoapBindingExtElement();
    addBindingOperation();
    wsdlDefinition.addBinding(binding);
    WSDLWriter wsdlWriter = wsdlFactory.newWSDLWriter();
    Writer outputWriter = getOutputWriter(NEW_FILE_NAME_MODIFIER);
    try {
        wsdlWriter.writeWSDL(wsdlDefinition, outputWriter);
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_WRITE_WSDL", LOG, wse.getMessage());
        throw new ToolException(msg);
    }
    try {
        outputWriter.close();
    } catch (IOException ioe) {
        Message msg = new Message("PORTTYPE_NOT_EXIST", LOG);
        throw new ToolException(msg);
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) WSDLException(javax.wsdl.WSDLException) QName(javax.xml.namespace.QName) WSDLWriter(javax.wsdl.xml.WSDLWriter) ToolException(org.apache.cxf.tools.common.ToolException) IOException(java.io.IOException) WSDLWriter(javax.wsdl.xml.WSDLWriter) Writer(java.io.Writer)

Example 8 with WSDLWriter

use of javax.wsdl.xml.WSDLWriter in project cxf by apache.

the class XSDToWSDLProcessor method addWSDLTypes.

private void addWSDLTypes() throws ToolException {
    Element sourceElement = this.xsdDoc.getDocumentElement();
    Element targetElement = (Element) sourceElement.cloneNode(true);
    this.wsdlDefinition.setTargetNamespace((String) env.get(ToolConstants.CFG_NAMESPACE));
    this.wsdlDefinition.setQName(new QName(WSDLConstants.NS_WSDL11, (String) env.get(ToolConstants.CFG_NAME)));
    Types types = this.wsdlDefinition.createTypes();
    ExtensibilityElement extElement;
    try {
        registry = wsdlFactory.newPopulatedExtensionRegistry();
        registerJAXWSBinding(Definition.class);
        registerJAXWSBinding(Types.class);
        registerJAXWSBinding(Schema.class);
        extElement = registry.createExtension(Types.class, WSDLConstants.QNAME_SCHEMA);
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_CREATE_SCHEMA_EXTENSION", LOG);
        throw new ToolException(msg, wse);
    }
    ((Schema) extElement).setElement(targetElement);
    types.addExtensibilityElement(extElement);
    this.wsdlDefinition.setTypes(types);
    WSDLWriter wsdlWriter = wsdlFactory.newWSDLWriter();
    Writer outputWriter = getOutputWriter();
    try {
        wsdlWriter.writeWSDL(wsdlDefinition, outputWriter);
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_WRITE_WSDL", LOG);
        throw new ToolException(msg, wse);
    }
    try {
        outputWriter.close();
    } catch (IOException ioe) {
        Message msg = new Message("FAIL_TO_CLOSE_WSDL_FILE", LOG);
        throw new ToolException(msg, ioe);
    }
}
Also used : Types(javax.wsdl.Types) Message(org.apache.cxf.common.i18n.Message) WSDLException(javax.wsdl.WSDLException) QName(javax.xml.namespace.QName) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Element(org.w3c.dom.Element) Schema(javax.wsdl.extensions.schema.Schema) ToolException(org.apache.cxf.tools.common.ToolException) WSDLWriter(javax.wsdl.xml.WSDLWriter) IOException(java.io.IOException) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) WSDLWriter(javax.wsdl.xml.WSDLWriter) Writer(java.io.Writer)

Example 9 with WSDLWriter

use of javax.wsdl.xml.WSDLWriter in project jbossws-cxf by jbossws.

the class WSDLFilePublisher method getWsdlDocument.

private static Document getWsdlDocument(Bus bus, Definition def) throws WSDLException {
    WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter();
    def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
    return wsdlWriter.getDocument(def);
}
Also used : WSDLWriter(javax.wsdl.xml.WSDLWriter)

Example 10 with WSDLWriter

use of javax.wsdl.xml.WSDLWriter in project cxf by apache.

the class AbstractAegisTest method getWSDLDocument.

protected Document getWSDLDocument(String string) throws WSDLException {
    Definition definition = getWSDLDefinition(string);
    if (definition == null) {
        return null;
    }
    WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
    return writer.getDocument(definition);
}
Also used : Definition(javax.wsdl.Definition) WSDLWriter(javax.wsdl.xml.WSDLWriter)

Aggregations

WSDLWriter (javax.wsdl.xml.WSDLWriter)22 Definition (javax.wsdl.Definition)14 HashMap (java.util.HashMap)9 IOException (java.io.IOException)7 WSDLException (javax.wsdl.WSDLException)7 Bus (org.apache.cxf.Bus)7 ServiceWSDLBuilder (org.apache.cxf.wsdl11.ServiceWSDLBuilder)7 Element (org.w3c.dom.Element)7 Writer (java.io.Writer)6 Server (org.apache.cxf.endpoint.Server)6 XPathUtils (org.apache.cxf.helpers.XPathUtils)6 ToolException (org.apache.cxf.tools.common.ToolException)6 Message (org.apache.cxf.common.i18n.Message)5 File (java.io.File)4 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)4 LocalTransportFactory (org.apache.cxf.transport.local.LocalTransportFactory)4 Document (org.w3c.dom.Document)4 QName (javax.xml.namespace.QName)3 EndpointPolicy (org.apache.cxf.ws.policy.EndpointPolicy)3 PolicyEngine (org.apache.cxf.ws.policy.PolicyEngine)3