Search in sources :

Example 41 with Part

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

the class ExceptionVisitor method createFaultMessage.

private void createFaultMessage(QName qname) {
    String exceptionName = qname.getLocalPart();
    // messages
    Message faultMsg = definition.createMessage();
    faultMsg.setQName(new QName(definition.getTargetNamespace(), exceptionName));
    faultMsg.setUndefined(false);
    // message - part
    Part part = definition.createPart();
    part.setName("exception");
    part.setElementName(qname);
    faultMsg.addPart(part);
    // add the fault element namespace to the definition
    String nsURI = qname.getNamespaceURI();
    manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(nsURI), nsURI);
    definition.addMessage(faultMsg);
}
Also used : Message(javax.wsdl.Message) QName(javax.xml.namespace.QName) Part(javax.wsdl.Part)

Example 42 with Part

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

the class WSIBPValidator method checkR2201Input.

private boolean checkR2201Input(final Operation operation, final BindingOperation bop) {
    List<Part> partsList = wsdlHelper.getInMessageParts(operation);
    int inmessagePartsCount = partsList.size();
    SoapBody soapBody = SOAPBindingUtil.getBindingInputSOAPBody(bop);
    if (soapBody != null) {
        List<?> parts = soapBody.getParts();
        int boundPartSize = parts == null ? inmessagePartsCount : parts.size();
        SoapHeader soapHeader = SOAPBindingUtil.getBindingInputSOAPHeader(bop);
        boundPartSize = soapHeader != null && soapHeader.getMessage().equals(operation.getInput().getMessage().getQName()) ? boundPartSize - 1 : boundPartSize;
        if (parts != null) {
            Iterator<?> partsIte = parts.iterator();
            while (partsIte.hasNext()) {
                String partName = (String) partsIte.next();
                boolean isDefined = false;
                for (Part part : partsList) {
                    if (partName.equalsIgnoreCase(part.getName())) {
                        isDefined = true;
                        break;
                    }
                }
                if (!isDefined) {
                    addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2201") + "Operation '" + operation.getName() + "' soapBody parts : " + partName + " not found in the message, wrong WSDL");
                    return false;
                }
            }
        } else {
            if (partsList.size() > 1) {
                addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2210") + "Operation '" + operation.getName() + "' more than one part bound to body");
                return false;
            }
        }
        if (boundPartSize > 1) {
            addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2201") + "Operation '" + operation.getName() + "' more than one part bound to body");
            return false;
        }
    }
    return true;
}
Also used : Part(javax.wsdl.Part) MIMEPart(javax.wsdl.extensions.mime.MIMEPart) SoapBody(org.apache.cxf.binding.soap.wsdl.extensions.SoapBody) SoapHeader(org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader)

Example 43 with Part

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

the class WSIBPValidator method checkR2205.

// TODO: Should also check SoapHeader/SoapHeaderFault
public boolean checkR2205() {
    Collection<Binding> bindings = CastUtils.cast(def.getBindings().values());
    for (Binding binding : bindings) {
        if (!SOAPBindingUtil.isSOAPBinding(binding)) {
            System.err.println("WSIBP Validator found <" + binding.getQName() + "> is NOT a SOAP binding");
            continue;
        }
        if (binding.getPortType() == null) {
            // will error later
            continue;
        }
        for (Iterator<?> ite2 = binding.getPortType().getOperations().iterator(); ite2.hasNext(); ) {
            Operation operation = (Operation) ite2.next();
            Collection<Fault> faults = CastUtils.cast(operation.getFaults().values());
            if (CollectionUtils.isEmpty(faults)) {
                continue;
            }
            for (Fault fault : faults) {
                Message message = fault.getMessage();
                Collection<Part> parts = CastUtils.cast(message.getParts().values());
                for (Part part : parts) {
                    if (part.getElementName() == null) {
                        addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2205") + "In Message " + message.getQName() + ", part " + part.getName() + " must specify a 'element' attribute");
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
Also used : SOAPBinding(javax.jws.soap.SOAPBinding) Binding(javax.wsdl.Binding) Message(javax.wsdl.Message) Part(javax.wsdl.Part) MIMEPart(javax.wsdl.extensions.mime.MIMEPart) Fault(javax.wsdl.Fault) SoapFault(org.apache.cxf.binding.soap.wsdl.extensions.SoapFault) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation)

Example 44 with Part

use of javax.wsdl.Part in project carbon-business-process by wso2.

the class SOAPUtils method parseSoapFault.

public static Fault parseSoapFault(Element odeMsgEl, SOAPEnvelope envelope, Operation operation) throws AxisFault {
    SOAPFault flt = envelope.getBody().getFault();
    SOAPFaultDetail detail = flt.getDetail();
    Fault fdef = inferFault(operation, flt);
    if (fdef == null) {
        return null;
    }
    Part pdef = (Part) fdef.getMessage().getParts().values().iterator().next();
    Element partel = odeMsgEl.getOwnerDocument().createElementNS(null, pdef.getName());
    odeMsgEl.appendChild(partel);
    if (detail.getFirstChildWithName(pdef.getElementName()) != null) {
        partel.appendChild(odeMsgEl.getOwnerDocument().importNode(OMUtils.toDOM(detail.getFirstChildWithName(pdef.getElementName())), true));
    } else {
        partel.appendChild(odeMsgEl.getOwnerDocument().importNode(OMUtils.toDOM(detail), true));
    }
    return fdef;
}
Also used : Part(javax.wsdl.Part) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) SOAPFaultDetail(org.apache.axiom.soap.SOAPFaultDetail) SOAPFault(org.apache.axiom.soap.SOAPFault) SOAPFault(org.apache.axiom.soap.SOAPFault) Fault(javax.wsdl.Fault) AxisFault(org.apache.axis2.AxisFault) BPELFault(org.wso2.carbon.bpel.core.ode.integration.BPELFault)

Example 45 with Part

use of javax.wsdl.Part in project ofbiz-framework by apache.

the class ModelService method getWSDL.

public void getWSDL(Definition def, String locationURI) throws WSDLException {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = null;
    Document document = null;
    try {
        builder = factory.newDocumentBuilder();
        document = builder.newDocument();
    } catch (Exception e) {
        throw new WSDLException("can not create WSDL", module);
    }
    def.setTypes(this.getTypes(document, def));
    // set the IN parameters
    Input input = def.createInput();
    Set<String> inParam = this.getInParamNames();
    Message inMessage = def.createMessage();
    inMessage.setQName(new QName(TNS, this.name + "Request"));
    inMessage.setUndefined(false);
    Part parametersPart = def.createPart();
    parametersPart.setName("map-Map");
    parametersPart.setTypeName(new QName(TNS, "map-Map"));
    inMessage.addPart(parametersPart);
    Element documentation = document.createElement("wsdl:documentation");
    for (String paramName : inParam) {
        ModelParam param = this.getParam(paramName);
        if (!param.internal) {
            Part part = param.getWSDLPart(def);
            Element attribute = document.createElement("attribute");
            attribute.setAttribute("name", paramName);
            attribute.setAttribute("type", part.getTypeName().getLocalPart());
            attribute.setAttribute("namespace", part.getTypeName().getNamespaceURI());
            attribute.setAttribute("java-class", param.type);
            attribute.setAttribute("optional", Boolean.toString(param.optional));
            documentation.appendChild(attribute);
        }
    }
    Element usernameAttr = document.createElement("attribute");
    usernameAttr.setAttribute("name", "login.username");
    usernameAttr.setAttribute("type", "std-String");
    usernameAttr.setAttribute("namespace", TNS);
    usernameAttr.setAttribute("java-class", String.class.getName());
    usernameAttr.setAttribute("optional", Boolean.toString(!this.auth));
    documentation.appendChild(usernameAttr);
    Element passwordAttr = document.createElement("attribute");
    passwordAttr.setAttribute("name", "login.password");
    passwordAttr.setAttribute("type", "std-String");
    passwordAttr.setAttribute("namespace", TNS);
    passwordAttr.setAttribute("java-class", String.class.getName());
    passwordAttr.setAttribute("optional", Boolean.toString(!this.auth));
    documentation.appendChild(passwordAttr);
    parametersPart.setDocumentationElement(documentation);
    def.addMessage(inMessage);
    input.setMessage(inMessage);
    // set the OUT parameters
    Output output = def.createOutput();
    Set<String> outParam = this.getOutParamNames();
    Message outMessage = def.createMessage();
    outMessage.setQName(new QName(TNS, this.name + "Response"));
    outMessage.setUndefined(false);
    Part resultsPart = def.createPart();
    resultsPart.setName("map-Map");
    resultsPart.setTypeName(new QName(TNS, "map-Map"));
    outMessage.addPart(resultsPart);
    documentation = document.createElement("wsdl:documentation");
    for (String paramName : outParam) {
        ModelParam param = this.getParam(paramName);
        if (!param.internal) {
            Part part = param.getWSDLPart(def);
            Element attribute = document.createElement("attribute");
            attribute.setAttribute("name", paramName);
            attribute.setAttribute("type", part.getTypeName().getLocalPart());
            attribute.setAttribute("namespace", part.getTypeName().getNamespaceURI());
            attribute.setAttribute("java-class", param.type);
            attribute.setAttribute("optional", Boolean.toString(param.optional));
            documentation.appendChild(attribute);
        }
    }
    resultsPart.setDocumentationElement(documentation);
    def.addMessage(outMessage);
    output.setMessage(outMessage);
    // set port type
    Operation operation = def.createOperation();
    operation.setName(this.name);
    operation.setUndefined(false);
    operation.setOutput(output);
    operation.setInput(input);
    PortType portType = def.createPortType();
    portType.setQName(new QName(TNS, this.name + "PortType"));
    portType.addOperation(operation);
    portType.setUndefined(false);
    def.addPortType(portType);
    // SOAP binding
    SOAPBinding soapBinding = new SOAPBindingImpl();
    soapBinding.setStyle("rpc");
    soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
    Binding binding = def.createBinding();
    binding.setQName(new QName(TNS, this.name + "SoapBinding"));
    binding.setPortType(portType);
    binding.setUndefined(false);
    binding.addExtensibilityElement(soapBinding);
    BindingOperation bindingOperation = def.createBindingOperation();
    bindingOperation.setName(operation.getName());
    bindingOperation.setOperation(operation);
    SOAPBody soapBody = new SOAPBodyImpl();
    soapBody.setUse("literal");
    soapBody.setNamespaceURI(TNS);
    soapBody.setEncodingStyles(UtilMisc.toList("http://schemas.xmlsoap.org/soap/encoding/"));
    BindingOutput bindingOutput = def.createBindingOutput();
    bindingOutput.addExtensibilityElement(soapBody);
    bindingOperation.setBindingOutput(bindingOutput);
    BindingInput bindingInput = def.createBindingInput();
    bindingInput.addExtensibilityElement(soapBody);
    bindingOperation.setBindingInput(bindingInput);
    SOAPOperation soapOperation = new SOAPOperationImpl();
    // soapAction should be set to the location of the SOAP URI, or Visual Studio won't construct the correct SOAP message
    soapOperation.setSoapActionURI(locationURI);
    // this is the RPC/literal style.  See http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
    // this parameter is necessary or Apache Synapse won't recognize the WSDL
    soapOperation.setStyle("rpc");
    bindingOperation.addExtensibilityElement(soapOperation);
    binding.addBindingOperation(bindingOperation);
    def.addBinding(binding);
    // Service port
    Port port = def.createPort();
    port.setBinding(binding);
    port.setName(this.name + "Port");
    if (locationURI != null) {
        SOAPAddress soapAddress = new SOAPAddressImpl();
        soapAddress.setLocationURI(locationURI);
        port.addExtensibilityElement(soapAddress);
    }
    Service service = def.createService();
    service.setQName(new QName(TNS, this.name));
    service.addPort(port);
    def.addService(service);
}
Also used : SOAPAddressImpl(com.ibm.wsdl.extensions.soap.SOAPAddressImpl) BindingOutput(javax.wsdl.BindingOutput) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Message(javax.wsdl.Message) Element(org.w3c.dom.Element) Port(javax.wsdl.Port) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) SOAPBodyImpl(com.ibm.wsdl.extensions.soap.SOAPBodyImpl) Document(org.w3c.dom.Document) BindingInput(javax.wsdl.BindingInput) Input(javax.wsdl.Input) BindingInput(javax.wsdl.BindingInput) BindingOperation(javax.wsdl.BindingOperation) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) Binding(javax.wsdl.Binding) WSDLException(javax.wsdl.WSDLException) QName(javax.xml.namespace.QName) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) Service(javax.wsdl.Service) SOAPOperationImpl(com.ibm.wsdl.extensions.soap.SOAPOperationImpl) GeneralException(org.apache.ofbiz.base.util.GeneralException) NoSuchElementException(java.util.NoSuchElementException) WSDLException(javax.wsdl.WSDLException) SOAPBody(javax.wsdl.extensions.soap.SOAPBody) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Part(javax.wsdl.Part) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) SOAPBindingImpl(com.ibm.wsdl.extensions.soap.SOAPBindingImpl) PortType(javax.wsdl.PortType)

Aggregations

Part (javax.wsdl.Part)49 QName (javax.xml.namespace.QName)30 Message (javax.wsdl.Message)21 Operation (javax.wsdl.Operation)11 BindingOperation (javax.wsdl.BindingOperation)9 Input (javax.wsdl.Input)9 Output (javax.wsdl.Output)7 OMElement (org.apache.axiom.om.OMElement)7 Element (org.w3c.dom.Element)7 ArrayList (java.util.ArrayList)6 Binding (javax.wsdl.Binding)6 OpenEJBException (org.apache.openejb.OpenEJBException)6 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)6 Fault (javax.wsdl.Fault)5 Port (javax.wsdl.Port)5 Service (javax.wsdl.Service)5 MIMEPart (javax.wsdl.extensions.mime.MIMEPart)5 List (java.util.List)4 BindingInput (javax.wsdl.BindingInput)4 PortType (javax.wsdl.PortType)4