Search in sources :

Example 16 with Input

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

the class WSDL11SOAPOperationExtractor method getSoapInputParameterModel.

/**
 * Gets swagger input parameter model for a given soap operation
 *
 * @param bindingOperation soap operation
 * @return list of swagger models for the parameters
 * @throws APIMgtWSDLException
 */
private List<ModelImpl> getSoapInputParameterModel(BindingOperation bindingOperation) throws APIMgtWSDLException {
    List<ModelImpl> inputParameterModelList = new ArrayList<>();
    Operation operation = bindingOperation.getOperation();
    if (operation != null) {
        Input input = operation.getInput();
        if (input != null) {
            Message message = input.getMessage();
            if (message != null) {
                Map map = message.getParts();
                for (Object obj : map.entrySet()) {
                    Map.Entry entry = (Map.Entry) obj;
                    Part part = (Part) entry.getValue();
                    if (part != null) {
                        if (part.getElementName() != null) {
                            inputParameterModelList.add(parameterModelMap.get(part.getElementName().getLocalPart()));
                        } else {
                            if (part.getTypeName() != null && parameterModelMap.containsKey(part.getTypeName().getLocalPart())) {
                                inputParameterModelList.add(parameterModelMap.get(part.getTypeName().getLocalPart()));
                            } else if (part.getTypeName() != null && parameterModelMap.containsKey(message.getQName().getLocalPart())) {
                                ModelImpl model = parameterModelMap.get(message.getQName().getLocalPart());
                                model.addProperty(part.getName(), getPropertyFromDataType(part.getTypeName().getLocalPart()));
                                parameterModelMap.put(model.getName(), model);
                                inputParameterModelList.add(model);
                            } else {
                                ModelImpl model;
                                if (parameterModelMap.get(message.getQName().getLocalPart()) != null) {
                                    model = parameterModelMap.get(message.getQName().getLocalPart());
                                } else {
                                    model = new ModelImpl();
                                    model.setType(ObjectProperty.TYPE);
                                    model.setName(message.getQName().getLocalPart());
                                }
                                if (getPropertyFromDataType(part.getTypeName().getLocalPart()) instanceof RefProperty) {
                                    RefProperty property = (RefProperty) getPropertyFromDataType(part.getTypeName().getLocalPart());
                                    property.set$ref(SOAPToRESTConstants.Swagger.DEFINITIONS_ROOT + part.getTypeName().getLocalPart());
                                    model.addProperty(part.getName(), property);
                                } else {
                                    model.addProperty(part.getName(), getPropertyFromDataType(part.getTypeName().getLocalPart()));
                                }
                                parameterModelMap.put(model.getName(), model);
                                inputParameterModelList.add(model);
                            }
                        }
                    }
                }
            }
        }
    }
    return inputParameterModelList;
}
Also used : Input(javax.wsdl.Input) Message(javax.wsdl.Message) Part(javax.wsdl.Part) ArrayList(java.util.ArrayList) Operation(javax.wsdl.Operation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) WSDLSOAPOperation(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation) BindingOperation(javax.wsdl.BindingOperation) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) WSDLOperation(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLOperation) ModelImpl(io.swagger.models.ModelImpl) Map(java.util.Map) HashMap(java.util.HashMap) NamedNodeMap(org.w3c.dom.NamedNodeMap) RefProperty(io.swagger.models.properties.RefProperty)

Example 17 with Input

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

the class WSDLHelper method getInMessageParts.

public List<Part> getInMessageParts(Operation operation) {
    Input input = operation.getInput();
    List<Part> partsList = new ArrayList<>();
    if (input != null && input.getMessage() != null) {
        Collection<Part> parts = CastUtils.cast(input.getMessage().getParts().values());
        for (Part p : parts) {
            partsList.add(p);
        }
    }
    return partsList;
}
Also used : Input(javax.wsdl.Input) Part(javax.wsdl.Part) ArrayList(java.util.ArrayList)

Example 18 with Input

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

the class WSDLServiceBuilder method buildInterfaceOperation.

private void buildInterfaceOperation(InterfaceInfo inf, Operation op) {
    OperationInfo opInfo = inf.addOperation(new QName(inf.getName().getNamespaceURI(), op.getName()));
    if (recordOriginal) {
        opInfo.setProperty(WSDL_OPERATION, op);
    }
    copyDocumentation(opInfo, op);
    List<String> porderList = CastUtils.cast((List<?>) op.getParameterOrdering());
    opInfo.setParameterOrdering(porderList);
    this.copyExtensors(opInfo, op.getExtensibilityElements());
    this.copyExtensionAttributes(opInfo, op);
    Input input = op.getInput();
    if (input != null) {
        if (input.getMessage() == null) {
            throw new WSDLRuntimeException(LOG, "NO_MESSAGE", "input", op.getName(), input.getName());
        }
        MessageInfo minfo = opInfo.createMessage(input.getMessage().getQName(), MessageInfo.Type.INPUT);
        opInfo.setInput(input.getName(), minfo);
        buildMessage(minfo, input.getMessage());
        copyExtensors(minfo, input.getExtensibilityElements());
        copyExtensionAttributes(minfo, input);
    }
    Output output = op.getOutput();
    if (output != null) {
        if (output.getMessage() == null) {
            throw new WSDLRuntimeException(LOG, "NO_MESSAGE", "output", op.getName(), output.getName());
        }
        MessageInfo minfo = opInfo.createMessage(output.getMessage().getQName(), MessageInfo.Type.OUTPUT);
        opInfo.setOutput(output.getName(), minfo);
        buildMessage(minfo, output.getMessage());
        copyExtensors(minfo, output.getExtensibilityElements());
        copyExtensionAttributes(minfo, output);
    }
    Map<?, ?> m = op.getFaults();
    for (Map.Entry<?, ?> rawentry : m.entrySet()) {
        Map.Entry<String, Fault> entry = cast(rawentry, String.class, Fault.class);
        FaultInfo finfo = opInfo.addFault(new QName(inf.getName().getNamespaceURI(), entry.getKey()), entry.getValue().getMessage().getQName());
        copyDocumentation(finfo, entry.getValue());
        buildMessage(finfo, entry.getValue().getMessage());
        copyExtensors(finfo, entry.getValue().getExtensibilityElements());
        copyExtensionAttributes(finfo, entry.getValue());
    }
    checkForWrapped(opInfo, allowRefs, false, unwrapLogLevel);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) UnwrappedOperationInfo(org.apache.cxf.service.model.UnwrappedOperationInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) QName(javax.xml.namespace.QName) Fault(javax.wsdl.Fault) BindingFault(javax.wsdl.BindingFault) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) Input(javax.wsdl.Input) Output(javax.wsdl.Output) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 19 with Input

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

the class OperationVisitor method generateInputMessage.

public Message generateInputMessage(Operation operation, BindingOperation bindingOperation) {
    Message msg = definition.createMessage();
    QName msgName;
    if (!mapper.isDefaultMapping()) {
        // mangle the message name
        // REVISIT, do we put in the entire scope for mangling
        msgName = new QName(definition.getTargetNamespace(), getScope().tail() + "." + operation.getName());
    } else {
        msgName = new QName(definition.getTargetNamespace(), operation.getName());
    }
    msg.setQName(msgName);
    msg.setUndefined(false);
    String inputName = operation.getName() + REQUEST_SUFFIX;
    Input input = definition.createInput();
    input.setName(inputName);
    input.setMessage(msg);
    BindingInput bindingInput = definition.createBindingInput();
    bindingInput.setName(inputName);
    bindingOperation.setBindingInput(bindingInput);
    operation.setInput(input);
    definition.addMessage(msg);
    return msg;
}
Also used : BindingInput(javax.wsdl.BindingInput) Input(javax.wsdl.Input) Message(javax.wsdl.Message) QName(javax.xml.namespace.QName) BindingInput(javax.wsdl.BindingInput)

Example 20 with Input

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

the class AttributeVisitor method generateOperation.

private Operation generateOperation(String name, Message inputMsg, Message outputMsg) {
    Input input = definition.createInput();
    input.setName(inputMsg.getQName().getLocalPart());
    input.setMessage(inputMsg);
    Output output = definition.createOutput();
    output.setName(outputMsg.getQName().getLocalPart());
    output.setMessage(outputMsg);
    Operation result = definition.createOperation();
    result.setName(name);
    result.setInput(input);
    result.setOutput(output);
    result.setUndefined(false);
    portType.addOperation(result);
    return result;
}
Also used : BindingInput(javax.wsdl.BindingInput) Input(javax.wsdl.Input) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation)

Aggregations

Input (javax.wsdl.Input)25 Message (javax.wsdl.Message)20 Operation (javax.wsdl.Operation)18 BindingOperation (javax.wsdl.BindingOperation)15 Output (javax.wsdl.Output)15 QName (javax.xml.namespace.QName)13 Part (javax.wsdl.Part)12 BindingInput (javax.wsdl.BindingInput)8 Map (java.util.Map)7 BindingOutput (javax.wsdl.BindingOutput)6 Fault (javax.wsdl.Fault)6 PortType (javax.wsdl.PortType)6 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 SOAP12Operation (javax.wsdl.extensions.soap12.SOAP12Operation)5 Binding (javax.wsdl.Binding)4 Test (org.junit.Test)4 Collection (java.util.Collection)3 BindingFault (javax.wsdl.BindingFault)3