Search in sources :

Example 31 with ToolException

use of org.apache.cxf.tools.common.ToolException in project cxf by apache.

the class WSDLToSoapProcessor method setSoapFaultExtElement.

private void setSoapFaultExtElement(BindingFault bf) throws ToolException {
    if (extReg == null) {
        extReg = wsdlFactory.newPopulatedExtensionRegistry();
    }
    SoapFault soapFault = null;
    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 32 with ToolException

use of org.apache.cxf.tools.common.ToolException in project cxf by apache.

the class WSDLToSoapProcessor method validate.

private void validate() throws ToolException {
    if (isBindingExisted()) {
        Message msg = new Message("BINDING_ALREADY_EXIST", LOG);
        throw new ToolException(msg);
    }
    if (!isPortTypeExisted()) {
        Message msg = new Message("PORTTYPE_NOT_EXIST", LOG);
        throw new ToolException(msg);
    }
    if (!nameSpaceCheck()) {
        Message msg = new Message("SOAPBINDING_STYLE_NOT_PROVIDED", LOG);
        throw new ToolException(msg);
    }
    if (WSDLConstants.RPC.equalsIgnoreCase((String) env.get(ToolConstants.CFG_STYLE))) {
        Collection<Operation> ops = CastUtils.cast(portType.getOperations());
        for (Operation op : ops) {
            Input input = op.getInput();
            if (input != null && input.getMessage() != null) {
                Collection<Part> parts = CastUtils.cast(input.getMessage().getParts().values());
                for (Part part : parts) {
                    if (part.getTypeName() == null || "".equals(part.getTypeName().toString())) {
                        Message msg = new Message("RPC_PART_ILLEGAL", LOG, new Object[] { part.getName() });
                        throw new ToolException(msg);
                    }
                }
            }
            Output output = op.getOutput();
            if (output != null && output.getMessage() != null) {
                Collection<Part> parts = CastUtils.cast(output.getMessage().getParts().values());
                for (Part part : parts) {
                    if (part.getTypeName() == null || "".equals(part.getTypeName().toString())) {
                        Message msg = new Message("RPC_PART_ILLEGAL", LOG, new Object[] { part.getName() });
                        throw new ToolException(msg);
                    }
                }
            }
        }
    }
}
Also used : BindingInput(javax.wsdl.BindingInput) Input(javax.wsdl.Input) Message(org.apache.cxf.common.i18n.Message) Part(javax.wsdl.Part) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output) ToolException(org.apache.cxf.tools.common.ToolException) Operation(javax.wsdl.Operation) SoapOperation(org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation) BindingOperation(javax.wsdl.BindingOperation)

Example 33 with ToolException

use of org.apache.cxf.tools.common.ToolException in project cxf by apache.

the class WSDLToSoapProcessor method getSoapBody.

private SoapBody getSoapBody(Class<?> parent) throws ToolException {
    if (extReg == null) {
        extReg = wsdlFactory.newPopulatedExtensionRegistry();
    }
    SoapBody soapBody = null;
    try {
        soapBody = SOAPBindingUtil.createSoapBody(extReg, parent, isSOAP12());
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
        throw new ToolException(msg, wse);
    }
    soapBody.setUse((String) env.get(ToolConstants.CFG_USE));
    if (WSDLConstants.RPC.equalsIgnoreCase((String) env.get(ToolConstants.CFG_STYLE)) && env.optionSet(ToolConstants.CFG_NAMESPACE)) {
        soapBody.setNamespaceURI((String) env.get(ToolConstants.CFG_NAMESPACE));
    }
    return soapBody;
}
Also used : Message(org.apache.cxf.common.i18n.Message) WSDLException(javax.wsdl.WSDLException) SoapBody(org.apache.cxf.binding.soap.wsdl.extensions.SoapBody) ToolException(org.apache.cxf.tools.common.ToolException)

Example 34 with ToolException

use of org.apache.cxf.tools.common.ToolException in project cxf by apache.

the class WSDLToSoapProcessor method setSoapBindingExtElement.

private void setSoapBindingExtElement() throws ToolException {
    if (extReg == null) {
        extReg = wsdlFactory.newPopulatedExtensionRegistry();
    }
    SOAPBindingUtil.addSOAPNamespace(wsdlDefinition, isSOAP12());
    SoapBinding soapBinding = null;
    try {
        soapBinding = SOAPBindingUtil.createSoapBinding(extReg, isSOAP12());
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
        throw new ToolException(msg, wse);
    }
    soapBinding.setStyle((String) env.get(ToolConstants.CFG_STYLE));
    binding.addExtensibilityElement(soapBinding);
}
Also used : Message(org.apache.cxf.common.i18n.Message) WSDLException(javax.wsdl.WSDLException) ToolException(org.apache.cxf.tools.common.ToolException) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding)

Example 35 with ToolException

use of org.apache.cxf.tools.common.ToolException in project cxf by apache.

the class WSDLToSoapProcessor method setSoapOperationExtElement.

private void setSoapOperationExtElement(BindingOperation bo) throws ToolException {
    if (extReg == null) {
        extReg = wsdlFactory.newPopulatedExtensionRegistry();
    }
    SoapOperation soapOperation = null;
    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)

Aggregations

ToolException (org.apache.cxf.tools.common.ToolException)129 Message (org.apache.cxf.common.i18n.Message)69 IOException (java.io.IOException)38 File (java.io.File)30 QName (javax.xml.namespace.QName)19 WSDLException (javax.wsdl.WSDLException)18 BadUsageException (org.apache.cxf.tools.common.toolspec.parser.BadUsageException)16 ToolContext (org.apache.cxf.tools.common.ToolContext)15 XMLStreamException (javax.xml.stream.XMLStreamException)14 FileNotFoundException (java.io.FileNotFoundException)12 Test (org.junit.Test)12 Element (org.w3c.dom.Element)10 InputStream (java.io.InputStream)9 Writer (java.io.Writer)9 URISyntaxException (java.net.URISyntaxException)9 URL (java.net.URL)9 HashMap (java.util.HashMap)9 ArrayList (java.util.ArrayList)8 SoapBinding (org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding)8 WSDLWriter (javax.wsdl.xml.WSDLWriter)7