Search in sources :

Example 6 with Output

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

the class ServiceWSDLBuilderTest method testGreetMeOperation.

@Test
public void testGreetMeOperation() throws Exception {
    setupWSDL(WSDL_PATH);
    PortType portType = newDef.getPortType(new QName(newDef.getTargetNamespace(), "Greeter"));
    Operation greetMe = portType.getOperation("greetMe", "greetMeRequest", "greetMeResponse");
    assertNotNull(greetMe);
    assertEquals("greetMe", greetMe.getName());
    Input input = greetMe.getInput();
    assertNotNull(input);
    assertEquals("greetMeRequest", input.getName());
    Message message = input.getMessage();
    assertNotNull(message);
    assertEquals("greetMeRequest", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("in", message.getPart("in").getName());
    Output output = greetMe.getOutput();
    assertNotNull(output);
    assertEquals("greetMeResponse", output.getName());
    message = output.getMessage();
    assertNotNull(message);
    assertEquals("greetMeResponse", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("out", message.getPart("out").getName());
    assertEquals(0, greetMe.getFaults().size());
}
Also used : Input(javax.wsdl.Input) Message(javax.wsdl.Message) QName(javax.xml.namespace.QName) Output(javax.wsdl.Output) Operation(javax.wsdl.Operation) PortType(javax.wsdl.PortType) Test(org.junit.Test)

Example 7 with Output

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

the class WSDLParameter method processWrappedOutputParams.

private void processWrappedOutputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, SchemaCollection xmlSchemaList, List<ParamType> inputs, List<ParamType> outputs) throws Exception {
    Output output = operation.getOutput();
    if (output != null) {
        Message msg = output.getMessage();
        Part part = (Part) msg.getOrderedParts(null).iterator().next();
        XmlSchemaComplexType schemaType = null;
        XmlSchemaElement el = getElement(part, xmlSchemaList);
        if (el == null) {
            return;
        }
        if (el.getSchemaType() != null) {
            schemaType = (XmlSchemaComplexType) el.getSchemaType();
        }
        XmlSchemaSequence seq = (XmlSchemaSequence) schemaType.getParticle();
        if (seq != null) {
            for (XmlSchemaSequenceMember seqMember : seq.getItems()) {
                if (seqMember instanceof XmlSchemaElement) {
                    el = (XmlSchemaElement) seqMember;
                    processWrappedOutputParam(wsdlToCorbaBinding, el, inputs, outputs);
                }
            }
        }
    }
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) Message(javax.wsdl.Message) Part(javax.wsdl.Part) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Output(javax.wsdl.Output) XmlSchemaSequenceMember(org.apache.ws.commons.schema.XmlSchemaSequenceMember) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType)

Example 8 with Output

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

the class WSDLParameter method processOutputParams.

private void processOutputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, SchemaCollection xmlSchemaList, List<ParamType> inputs, List<ParamType> outputs) throws Exception {
    Output output = operation.getOutput();
    if (output != null) {
        Message msg = output.getMessage();
        List<Part> parts = CastUtils.cast(msg.getOrderedParts(null));
        for (Part part : parts) {
            XmlSchemaType schemaType = null;
            // check if in input list
            String mode = "out";
            ParamType paramtype = null;
            boolean isObjectRef = isObjectReference(xmlSchemaList, part.getElementName());
            for (int x = 0; x < inputs.size(); x++) {
                paramtype = null;
                ParamType d2 = inputs.get(x);
                if (part.getElementName() != null && !isObjectRef) {
                    XmlSchemaElement el = getElement(part, xmlSchemaList);
                    if (el != null) {
                        if (el.getSchemaType() != null) {
                            schemaType = el.getSchemaType();
                        }
                        QName typeName = el.getSchemaTypeName();
                        if (typeName == null) {
                            typeName = el.getQName();
                        }
                        QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, el.isNillable());
                        if ((d2.getName().equals(part.getName())) && (d2.getIdltype().equals(idltype))) {
                            inputs.remove(x);
                            paramtype = createParam(wsdlToCorbaBinding, "inout", part.getName(), idltype);
                            inputs.add(paramtype);
                        }
                    }
                } else {
                    schemaType = getType(part, xmlSchemaList);
                    QName typeName = part.getTypeName();
                    if (isObjectRef) {
                        typeName = part.getElementName();
                    }
                    QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
                    if ((d2.getName().equals(part.getName())) && (d2.getIdltype().equals(idltype))) {
                        inputs.remove(x);
                        paramtype = createParam(wsdlToCorbaBinding, "inout", part.getName(), idltype);
                        inputs.add(paramtype);
                    }
                }
            }
            if (paramtype == null) {
                if (part.getElementName() != null && !isObjectRef) {
                    XmlSchemaElement el = getElement(part, xmlSchemaList);
                    QName typeName = el.getSchemaTypeName();
                    if (typeName == null) {
                        typeName = el.getQName();
                    }
                    QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, el.isNillable());
                    paramtype = createParam(wsdlToCorbaBinding, mode, part.getName(), idltype);
                } else {
                    QName typeName = part.getTypeName();
                    if (isObjectRef) {
                        typeName = part.getElementName();
                    }
                    QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
                    paramtype = createParam(wsdlToCorbaBinding, mode, part.getName(), idltype);
                }
                if (paramtype != null) {
                    outputs.add(paramtype);
                }
            }
        }
    }
}
Also used : Message(javax.wsdl.Message) Part(javax.wsdl.Part) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) Output(javax.wsdl.Output) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Example 9 with Output

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

the class OperationVisitor method generateOutputMessage.

public Message generateOutputMessage(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() + RESPONSE_SUFFIX);
    } else {
        msgName = new QName(definition.getTargetNamespace(), operation.getName() + RESPONSE_SUFFIX);
    }
    msg.setQName(msgName);
    msg.setUndefined(false);
    String outputName = operation.getName() + RESPONSE_SUFFIX;
    Output output = definition.createOutput();
    output.setName(outputName);
    output.setMessage(msg);
    BindingOutput bindingOutput = definition.createBindingOutput();
    bindingOutput.setName(outputName);
    bindingOperation.setBindingOutput(bindingOutput);
    operation.setOutput(output);
    definition.addMessage(msg);
    return msg;
}
Also used : BindingOutput(javax.wsdl.BindingOutput) Message(javax.wsdl.Message) QName(javax.xml.namespace.QName) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output)

Example 10 with Output

use of javax.wsdl.Output 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)

Aggregations

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