Search in sources :

Example 1 with SOAP12Fault

use of javax.wsdl.extensions.soap12.SOAP12Fault in project eclipselink by eclipse-ee4j.

the class WSDLGenerator method createMethodDefinition.

private void createMethodDefinition(WSDLFactory factory, ExtensionRegistry registry, Definition def, Operation operation, boolean useSOAP12) throws WSDLException {
    Message requestMessage = def.createMessage();
    requestMessage.setUndefined(false);
    requestMessage.setQName(new QName(serviceNameSpace, operation.getName() + REQUEST_SUFFIX));
    Part requestPart = def.createPart();
    requestPart.setName(operation.getName() + REQUEST_SUFFIX);
    requestPart.setElementName(new QName(serviceNameSpace, operation.getName()));
    requestMessage.addPart(requestPart);
    def.addMessage(requestMessage);
    Message responseMessage = null;
    if (operation.hasResponse()) {
        responseMessage = def.createMessage();
        responseMessage.setUndefined(false);
        responseMessage.setQName(new QName(serviceNameSpace, operation.getName() + RESPONSE_SUFFIX));
        Part responsePart = def.createPart();
        responsePart.setName(operation.getName() + RESPONSE_SUFFIX);
        responsePart.setElementName(new QName(serviceNameSpace, operation.getName() + RESPONSE_SUFFIX));
        responseMessage.addPart(responsePart);
        def.addMessage(responseMessage);
    }
    PortType portType = def.getPortType(new QName(serviceNameSpace, serviceName + PORT_SUFFIX));
    javax.wsdl.Operation op = def.createOperation();
    op.setUndefined(false);
    op.setName(operation.getName());
    Input input = def.createInput();
    input.setMessage(requestMessage);
    op.setInput(input);
    if (operation.hasResponse()) {
        Output output = def.createOutput();
        output.setMessage(responseMessage);
        op.setOutput(output);
    }
    portType.addOperation(op);
    Binding binding = def.getBinding(new QName(serviceNameSpace, serviceName + BINDING_SUFFIX));
    BindingOperation bop = def.createBindingOperation();
    bop.setName(operation.getName());
    ExtensibilityElement so = null;
    if (useSOAP12) {
        so = registry.createExtension(BindingOperation.class, new QName(SOAP_12_NAMESPACE_URI, TAG_SOAP_OPERATION));
        ((SOAP12Operation) so).setSoapActionURI(serviceNameSpace + ":" + op.getName());
    } else {
        so = registry.createExtension(BindingOperation.class, new QName(SOAP_11_NAMESPACE_URI, TAG_SOAP_OPERATION));
        ((SOAPOperation) so).setSoapActionURI(serviceNameSpace + ":" + op.getName());
    }
    bop.addExtensibilityElement(so);
    BindingInput bi = def.createBindingInput();
    ExtensibilityElement soapInputBody = null;
    if (useSOAP12) {
        soapInputBody = registry.createExtension(BindingInput.class, new QName(SOAP_12_NAMESPACE_URI, TAG_SOAP_BODY));
        ((SOAP12Body) soapInputBody).setUse(SOAP_USE);
    } else {
        soapInputBody = registry.createExtension(BindingInput.class, new QName(SOAP_11_NAMESPACE_URI, TAG_SOAP_BODY));
        ((SOAPBody) soapInputBody).setUse(SOAP_USE);
    }
    bi.addExtensibilityElement(soapInputBody);
    bop.setBindingInput(bi);
    if (operation.hasResponse()) {
        BindingOutput bo = def.createBindingOutput();
        ExtensibilityElement soapOutputBody = null;
        if (useSOAP12) {
            soapOutputBody = registry.createExtension(BindingOutput.class, new QName(SOAP_12_NAMESPACE_URI, TAG_SOAP_BODY));
            ((SOAP12Body) soapOutputBody).setUse(SOAP_USE);
        } else {
            soapOutputBody = registry.createExtension(BindingOutput.class, new QName(SOAP_11_NAMESPACE_URI, TAG_SOAP_BODY));
            ((SOAPBody) soapOutputBody).setUse(SOAP_USE);
        }
        bo.addExtensibilityElement(soapOutputBody);
        bop.setBindingOutput(bo);
    }
    if (!(operation instanceof QueryOperation)) {
        // non-QueryOperations don't have Responses, but the fault requirements
        // mean we have to create 'dummy' WSDL outputs
        BindingOutput bo = def.createBindingOutput();
        ExtensibilityElement soapOutputBody = null;
        if (useSOAP12) {
            soapOutputBody = registry.createExtension(BindingOutput.class, new QName(SOAP_12_NAMESPACE_URI, TAG_SOAP_BODY));
            ((SOAP12Body) soapOutputBody).setUse(SOAP_USE);
        } else {
            soapOutputBody = registry.createExtension(BindingOutput.class, new QName(SOAP_11_NAMESPACE_URI, TAG_SOAP_BODY));
            ((SOAPBody) soapOutputBody).setUse(SOAP_USE);
        }
        bo.addExtensibilityElement(soapOutputBody);
        bop.setBindingOutput(bo);
        // add WSDL fault to binding operations
        BindingFault bindingFault = def.createBindingFault();
        String exceptionName = FAULT_SUFFIX + EXCEPTION_SUFFIX;
        bindingFault.setName(exceptionName);
        ExtensibilityElement soapFaultBody = null;
        if (useSOAP12) {
            soapFaultBody = registry.createExtension(BindingFault.class, new QName(SOAP_12_NAMESPACE_URI, TAG_SOAP_FAULT));
            ((SOAP12Fault) soapFaultBody).setUse(SOAP_USE);
            ((SOAP12Fault) soapFaultBody).setName(exceptionName);
        } else {
            soapFaultBody = registry.createExtension(BindingFault.class, new QName(SOAP_11_NAMESPACE_URI, TAG_SOAP_FAULT));
            ((SOAPFault) soapFaultBody).setUse(SOAP_USE);
            ((SOAPFault) soapFaultBody).setName(exceptionName);
        }
        bindingFault.addExtensibilityElement(soapFaultBody);
        bop.addBindingFault(bindingFault);
        Message emptyResponseMessage = def.getMessage(new QName(serviceNameSpace, EMPTY_RESPONSE));
        Output output = def.createOutput();
        output.setName(operation.getName() + EMPTY_RESPONSE);
        output.setMessage(emptyResponseMessage);
        op.setOutput(output);
        Message faultMessage = def.getMessage(new QName(serviceNameSpace, FAULT_SUFFIX + TYPE_SUFFIX));
        Fault fault = def.createFault();
        fault.setMessage(faultMessage);
        fault.setName(exceptionName);
        op.addFault(fault);
    }
    binding.addBindingOperation(bop);
}
Also used : SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) BindingOutput(javax.wsdl.BindingOutput) Message(javax.wsdl.Message) SOAP12Body(javax.wsdl.extensions.soap12.SOAP12Body) BindingFault(javax.wsdl.BindingFault) QName(javax.xml.namespace.QName) SOAP12Fault(javax.wsdl.extensions.soap12.SOAP12Fault) Fault(javax.wsdl.Fault) BindingFault(javax.wsdl.BindingFault) SOAPFault(javax.wsdl.extensions.soap.SOAPFault) SOAP12Fault(javax.wsdl.extensions.soap12.SOAP12Fault) BindingInput(javax.wsdl.BindingInput) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Input(javax.wsdl.Input) BindingInput(javax.wsdl.BindingInput) BindingOperation(javax.wsdl.BindingOperation) SOAPBody(javax.wsdl.extensions.soap.SOAPBody) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) Part(javax.wsdl.Part) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output) SOAPFault(javax.wsdl.extensions.soap.SOAPFault) PortType(javax.wsdl.PortType) QueryOperation(org.eclipse.persistence.internal.xr.QueryOperation)

Aggregations

Binding (javax.wsdl.Binding)1 BindingFault (javax.wsdl.BindingFault)1 BindingInput (javax.wsdl.BindingInput)1 BindingOperation (javax.wsdl.BindingOperation)1 BindingOutput (javax.wsdl.BindingOutput)1 Fault (javax.wsdl.Fault)1 Input (javax.wsdl.Input)1 Message (javax.wsdl.Message)1 Output (javax.wsdl.Output)1 Part (javax.wsdl.Part)1 PortType (javax.wsdl.PortType)1 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)1 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)1 SOAPBody (javax.wsdl.extensions.soap.SOAPBody)1 SOAPFault (javax.wsdl.extensions.soap.SOAPFault)1 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)1 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)1 SOAP12Body (javax.wsdl.extensions.soap12.SOAP12Body)1 SOAP12Fault (javax.wsdl.extensions.soap12.SOAP12Fault)1 SOAP12Operation (javax.wsdl.extensions.soap12.SOAP12Operation)1