Search in sources :

Example 21 with WSDLException

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

the class AttributeVisitor method generateCorbaOperation.

/**
 * Generates a corba:operation in the corba:binding container within a wsdl:binding.
 *
 * Only one (or none) corba parameter and only one (or none) corba return parameter are supported.
 *
 * @param op is the wsdl operation to bind.
 * @param param is the corba parameter, none if null.
 * @param arg is the corba return parameter, none if null.
 * @return the generated corba:operation.
 */
private OperationType generateCorbaOperation(Operation op, ParamType param, ArgType arg) {
    final OperationType operation;
    try {
        operation = (OperationType) extReg.createExtension(BindingOperation.class, CorbaConstants.NE_CORBA_OPERATION);
    } catch (WSDLException ex) {
        throw new RuntimeException(ex);
    }
    operation.setName(op.getName());
    if (param != null) {
        operation.getParam().add(param);
    }
    if (arg != null) {
        operation.setReturn(arg);
    }
    return operation;
}
Also used : WSDLException(javax.wsdl.WSDLException) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType)

Example 22 with WSDLException

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

the class WSDLCorbaWriterImpl method getDocument.

public Document getDocument(Definition wsdlDef) throws WSDLException {
    try {
        fixTypes(wsdlDef);
    } catch (Exception ex) {
        throw new WSDLException(WSDLException.PARSER_ERROR, ex.getMessage(), ex);
    }
    Document doc = wrapped.getDocument(wsdlDef);
    Element imp = null;
    Element child = DOMUtils.getFirstElement(doc.getDocumentElement());
    // move extensability things to the top
    while (child != null) {
        if (child.getNamespaceURI().equals(doc.getDocumentElement().getNamespaceURI())) {
            // wsdl node
            if (imp == null) {
                imp = child;
            }
        } else if (imp != null) {
            doc.getDocumentElement().removeChild(child);
            doc.getDocumentElement().insertBefore(child, imp);
        }
        child = DOMUtils.getNextElement(child);
    }
    return doc;
}
Also used : WSDLException(javax.wsdl.WSDLException) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) WSDLException(javax.wsdl.WSDLException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) XMLStreamException(javax.xml.stream.XMLStreamException)

Example 23 with WSDLException

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

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

the class WSDLToSoapProcessor method getSoapBody.

private SoapBody getSoapBody(Class<?> parent) throws ToolException {
    if (extReg == null) {
        extReg = wsdlFactory.newPopulatedExtensionRegistry();
    }
    final SoapBody soapBody;
    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 25 with WSDLException

use of javax.wsdl.WSDLException 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());
    final SoapBinding soapBinding;
    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)

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