Search in sources :

Example 26 with WSDLException

use of javax.wsdl.WSDLException in project cxf by apache.

the class WSDLToSoapProcessor method setSoapOperationExtElement.

private void setSoapOperationExtElement(BindingOperation bo) throws ToolException {
    if (extReg == null) {
        extReg = wsdlFactory.newPopulatedExtensionRegistry();
    }
    final SoapOperation soapOperation;
    try {
        soapOperation = SOAPBindingUtil.createSoapOperation(extReg, isSOAP12());
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
        throw new ToolException(msg, wse);
    }
    soapOperation.setStyle((String) env.get(ToolConstants.CFG_STYLE));
    soapOperation.setSoapActionURI("");
    bo.addExtensibilityElement(soapOperation);
}
Also used : Message(org.apache.cxf.common.i18n.Message) WSDLException(javax.wsdl.WSDLException) SoapOperation(org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation) ToolException(org.apache.cxf.tools.common.ToolException)

Example 27 with WSDLException

use of javax.wsdl.WSDLException 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 28 with WSDLException

use of javax.wsdl.WSDLException in project cxf by apache.

the class WSDLToSoapProcessor method setSoapFaultExtElement.

private void setSoapFaultExtElement(BindingFault bf) throws ToolException {
    if (extReg == null) {
        extReg = wsdlFactory.newPopulatedExtensionRegistry();
    }
    final SoapFault soapFault;
    try {
        soapFault = SOAPBindingUtil.createSoapFault(extReg, isSOAP12());
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
        throw new ToolException(msg, wse);
    }
    soapFault.setName(bf.getName());
    soapFault.setUse((String) env.get(ToolConstants.CFG_USE));
    if (WSDLConstants.RPC.equalsIgnoreCase((String) env.get(ToolConstants.CFG_STYLE)) && env.optionSet(ToolConstants.CFG_NAMESPACE)) {
        soapFault.setNamespaceURI((String) env.get(ToolConstants.CFG_NAMESPACE));
    }
    bf.addExtensibilityElement(soapFault);
}
Also used : SoapFault(org.apache.cxf.binding.soap.wsdl.extensions.SoapFault) Message(org.apache.cxf.common.i18n.Message) WSDLException(javax.wsdl.WSDLException) ToolException(org.apache.cxf.tools.common.ToolException)

Example 29 with WSDLException

use of javax.wsdl.WSDLException 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 30 with WSDLException

use of javax.wsdl.WSDLException in project cxf by apache.

the class WSDLToServiceProcessor method setAddrElement.

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);
    }
}
Also used : Address(org.apache.cxf.tools.misc.processor.address.Address) Message(org.apache.cxf.common.i18n.Message) WSDLException(javax.wsdl.WSDLException) WSDLExtensibilityPlugin(org.apache.cxf.wsdl.WSDLExtensibilityPlugin) ToolException(org.apache.cxf.tools.common.ToolException) Map(java.util.Map) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Aggregations

WSDLException (javax.wsdl.WSDLException)56 ToolException (org.apache.cxf.tools.common.ToolException)18 WSDLReader (javax.wsdl.xml.WSDLReader)14 IOException (java.io.IOException)13 Definition (javax.wsdl.Definition)12 Message (org.apache.cxf.common.i18n.Message)12 QName (javax.xml.namespace.QName)11 WSDLWriter (javax.wsdl.xml.WSDLWriter)10 APIMgtWSDLException (org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException)7 File (java.io.File)6 Writer (java.io.Writer)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)6 Document (org.w3c.dom.Document)6 URL (java.net.URL)5 WSDLManager (org.apache.cxf.wsdl.WSDLManager)5 XMLStreamException (javax.xml.stream.XMLStreamException)4 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3