Search in sources :

Example 1 with Part

use of javax.wsdl.Part in project tdi-studio-se by Talend.

the class ComponentBuilder method getParameterFromMessage.

private void getParameterFromMessage(OperationInfo operationInfo, Message msg, int manner) {
    // inOrOut = manner;
    List msgParts = msg.getOrderedParts(null);
    // msg.getQName();
    // Schema wsdlType = null;
    // XmlSchema xmlSchema = null;
    Iterator iter = msgParts.iterator();
    while (iter.hasNext()) {
        Part part = (Part) iter.next();
        String partName = part.getName();
        String partElement = null;
        String namespace = null;
        if (part.getElementName() != null) {
            partElement = part.getElementName().getLocalPart();
            namespace = part.getElementName().getNamespaceURI();
        } else if (part.getTypeName() != null) {
            partElement = part.getTypeName().getLocalPart();
            namespace = part.getTypeName().getNamespaceURI();
        }
        // add first parameter from message.
        ParameterInfo parameterRoot = new ParameterInfo();
        parameterRoot.setName(partName);
        parameterRoot.setNameSpace(namespace);
        if (manner == 1) {
            operationInfo.addInparameter(parameterRoot);
        } else {
            operationInfo.addOutparameter(parameterRoot);
        }
        // }
        if (allXmlSchemaElement.size() > 0) {
            buildParameterFromElements(partElement, parameterRoot, manner);
        } else if (allXmlSchemaType.size() > 0) {
            buileParameterFromTypes(namespace, partElement, parameterRoot, manner);
        }
        operationInfo.setWsdltype(wsdlTypes);
    }
}
Also used : Part(javax.wsdl.Part) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)

Example 2 with Part

use of javax.wsdl.Part in project tesb-studio-se by Talend.

the class PublishMetadataRunnable method getParameterFromMessage.

private static QName getParameterFromMessage(Message msg) {
    // add first parameter from message.
    @SuppressWarnings("unchecked") Collection<Part> values = msg.getParts().values();
    if (values == null || values.isEmpty()) {
        return null;
    }
    Part part = values.iterator().next();
    if (part.getElementName() != null) {
        return part.getElementName();
    } else if (part.getTypeName() != null) {
        return part.getTypeName();
    }
    return null;
}
Also used : Part(javax.wsdl.Part)

Example 3 with Part

use of javax.wsdl.Part in project Lucee by lucee.

the class JaxWSClient method toDumpData.

private DumpData toDumpData(BindingOperation bo) {
    Map<QName, Message> messages = wsdl.getMessages();
    DumpTable table = new DumpTable("#99cc99", "#ccffcc", "#000000");
    DumpTable attributes = new DumpTable("#99cc99", "#ccffcc", "#000000");
    String returns = "void";
    attributes.appendRow(3, new SimpleDumpData("name"), new SimpleDumpData("type"));
    Operation op = bo.getOperation();
    // attributes
    Input in = op.getInput();
    Message msg = in.getMessage();
    // msg=WSUtil.getMessageByLocalName(messages,bo.getBindingInput().getName());
    // print.e(msg.getQName());
    List<Part> parts = msg.getOrderedParts(null);
    Iterator<Part> it = parts.iterator();
    Part p;
    QName en;
    QName type;
    while (it.hasNext()) {
        p = it.next();
        en = p.getElementName();
        if (en != null) {
            type = en;
            Types types = wsdl.getTypes();
        } else
            type = p.getTypeName();
        attributes.appendRow(0, new SimpleDumpData(en + ":" + p.getName()), new SimpleDumpData(toLuceeType(type)));
    }
    // return
    msg = bo.getOperation().getOutput().getMessage();
    msg = wsdl.getMessage(msg.getQName());
    parts = msg.getOrderedParts(null);
    it = parts.iterator();
    while (it.hasNext()) {
        p = it.next();
        returns = toLuceeType(p.getTypeName());
    }
    table.appendRow(1, new SimpleDumpData("arguments"), attributes);
    table.appendRow(1, new SimpleDumpData("return type"), new SimpleDumpData(returns));
    return table;
}
Also used : DumpTable(lucee.runtime.dump.DumpTable) Types(javax.wsdl.Types) Input(javax.wsdl.Input) Message(javax.wsdl.Message) QName(javax.xml.namespace.QName) Part(javax.wsdl.Part) SimpleDumpData(lucee.runtime.dump.SimpleDumpData) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation)

Example 4 with Part

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

the class WSDL11ProcessorImpl method getParameters.

/**
 * Returns parameters, given http binding operation, verb and content type
 *
 * @param bindingOperation {@link BindingOperation} object
 * @param verb             HTTP verb
 * @param contentType      Content type
 * @return parameters, given http binding operation, verb and content type
 */
private List<WSDLOperationParam> getParameters(BindingOperation bindingOperation, String verb, String contentType) {
    List<WSDLOperationParam> params = new ArrayList<>();
    Operation operation = bindingOperation.getOperation();
    // or content type is not provided
    if (APIMWSDLUtils.canContainBody(verb) && !APIMWSDLUtils.hasFormDataParams(contentType)) {
        WSDLOperationParam param = new WSDLOperationParam();
        param.setName("Payload");
        param.setParamType(WSDLOperationParam.ParamTypeEnum.BODY);
        params.add(param);
        if (log.isDebugEnabled()) {
            log.debug("Adding default Param for operation:" + operation.getName() + ", contentType: " + contentType);
        }
        return params;
    }
    if (operation != null) {
        Input input = operation.getInput();
        if (input != null) {
            Message message = input.getMessage();
            if (message != null) {
                Map map = message.getParts();
                map.forEach((name, partObj) -> {
                    WSDLOperationParam param = new WSDLOperationParam();
                    param.setName(name.toString());
                    if (log.isDebugEnabled()) {
                        log.debug("Identified param for operation: " + operation.getName() + " param: " + name);
                    }
                    if (APIMWSDLUtils.canContainBody(verb)) {
                        if (log.isDebugEnabled()) {
                            log.debug("Operation " + operation.getName() + " can contain a body.");
                        }
                        // In POST, PUT operations, parameters always in body according to HTTP Binding spec
                        if (APIMWSDLUtils.hasFormDataParams(contentType)) {
                            param.setParamType(WSDLOperationParam.ParamTypeEnum.FORM_DATA);
                            if (log.isDebugEnabled()) {
                                log.debug("Param " + name + " type was set to formData.");
                            }
                        }
                    // no else block since if content type is not form-data related, there can be only one
                    // parameter which is payload body. This is handled in the first if block which is
                    // if (canContainBody(verb) && !hasFormDataParams(contentType)) { .. }
                    } else {
                        // In GET operations, parameters always query or path as per HTTP Binding spec
                        if (isUrlReplacement(bindingOperation)) {
                            param.setParamType(WSDLOperationParam.ParamTypeEnum.PATH);
                            if (log.isDebugEnabled()) {
                                log.debug("Param " + name + " type was set to Path.");
                            }
                        } else {
                            param.setParamType(WSDLOperationParam.ParamTypeEnum.QUERY);
                            if (log.isDebugEnabled()) {
                                log.debug("Param " + name + " type was set to Query.");
                            }
                        }
                    }
                    Part part = (Part) partObj;
                    param.setDataType(part.getTypeName().getLocalPart());
                    if (log.isDebugEnabled()) {
                        log.debug("Param " + name + " data type was set to " + param.getDataType());
                    }
                    params.add(param);
                });
            }
        }
    }
    return params;
}
Also used : WSDLOperationParam(org.wso2.carbon.apimgt.core.models.WSDLOperationParam) Input(javax.wsdl.Input) BindingInput(javax.wsdl.BindingInput) Message(javax.wsdl.Message) Part(javax.wsdl.Part) ArrayList(java.util.ArrayList) Operation(javax.wsdl.Operation) HTTPOperation(javax.wsdl.extensions.http.HTTPOperation) BindingOperation(javax.wsdl.BindingOperation) WSDLOperation(org.wso2.carbon.apimgt.core.models.WSDLOperation) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with Part

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

the class SOAPUtils method handleSoapHeaderPartDef.

private static void handleSoapHeaderPartDef(org.apache.ode.bpel.iapi.Message odeMessage, Definition wsdl, SOAPHeader header, javax.wsdl.extensions.soap.SOAPHeader headerdef, Message msgType) throws BPELFault {
    // Is this header part of the "payload" messsage?
    boolean payloadMessageHeader = headerdef.getMessage() == null || headerdef.getMessage().equals(msgType.getQName());
    boolean requiredHeader = payloadMessageHeader || (headerdef.getRequired() != null && headerdef.getRequired());
    if (requiredHeader && header == null) {
        throw new BPELFault("SOAP Header missing required element.");
    }
    if (header == null) {
        return;
    }
    Message hdrMsg = wsdl.getMessage(headerdef.getMessage());
    if (hdrMsg == null) {
        return;
    }
    Part p = hdrMsg.getPart(headerdef.getPart());
    if (p == null || p.getElementName() == null) {
        return;
    }
    OMElement headerEl = header.getFirstChildWithName(p.getElementName());
    if (requiredHeader && headerEl == null) {
        throw new BPELFault("SOAP Header missing required element: " + p.getElementName());
    }
    if (headerEl == null) {
        return;
    }
    odeMessage.setHeaderPart(p.getName(), OMUtils.toDOM(headerEl));
}
Also used : BPELFault(org.wso2.carbon.bpel.core.ode.integration.BPELFault) Message(javax.wsdl.Message) Part(javax.wsdl.Part) OMElement(org.apache.axiom.om.OMElement)

Aggregations

Part (javax.wsdl.Part)53 QName (javax.xml.namespace.QName)30 Message (javax.wsdl.Message)25 Operation (javax.wsdl.Operation)15 BindingOperation (javax.wsdl.BindingOperation)13 Input (javax.wsdl.Input)12 ArrayList (java.util.ArrayList)8 Output (javax.wsdl.Output)8 HashMap (java.util.HashMap)7 Map (java.util.Map)7 OMElement (org.apache.axiom.om.OMElement)7 Element (org.w3c.dom.Element)7 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 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)5