Definition of WSDL raising exception

0

Hello, I have been trying to define a wsdl of a component that uses SOAP for an SOA project that mixes several types of services, integrating them with camel. But I am caught up in a problem that I see no sense in the answer he gives me, which I believe to be purely the definition of service.

This is my wsdl:

<wsdl:types>
    <xsd:schema targetNamespace="http://soapadapter.goodbooze.marlo.com.au/services/EntryService">
        <xsd:import schemaLocation="../entities/entryRequest.xsd"
                    namespace="http://soapadapter.goodbooze.marlo.com.au/entities/entryRequest"/>

        <xsd:import schemaLocation="../entities/entryResponse.xsd"
                    namespace="http://soapadapter.goodbooze.marlo.com.au/entities/entryResponse"/>

        <xsd:import schemaLocation="../entities/soapFault.xsd"
                    namespace="http://soapadapter.goodbooze.marlo.com.au/entities/soapFaultMessage"/>
    </xsd:schema>
</wsdl:types>

<wsdl:message name="entryRequest">
    <wsdl:part name="parameters" element="req:entryRequest"/>
</wsdl:message>

<wsdl:message name="entryResponse">
    <wsdl:part name="parameters" element="res:entryResponse"/>
</wsdl:message>

<wsdl:message name="entryRequestError">
    <wsdl:part name="soapChannelFault" element="sf:soapFaultMessage"/>
</wsdl:message>

<wsdl:portType name="entryService">
    <wsdl:operation name="postEntry">
        <wsdl:input message="entryRequest"/>
        <wsdl:output message="entryResponse"/>
        <wsdl:fault name="fault" message="entryRequestError" />
    </wsdl:operation>
</wsdl:portType>

    <wsdl:binding name="entryServiceBinding" type="entryService">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>

        <wsdl:operation name="postEntry">
            <soap:operation soapAction="action" style="document"/>

            <wsdl:input >
                <soap:body use="literal" parts="parameters"/>
            </wsdl:input>

            <wsdl:output >
                <soap:body use="literal" />
            </wsdl:output>

            <wsdl:fault name="fault">
                <soap:fault name="fault" use="literal"/>
            </wsdl:fault>

    </wsdl:operation>
</wsdl:binding>

<wsdl:service name="publishEntryService">
    <wsdl:port name="entryService" binding="entryServiceBinding">
        <soap:address location="http://localhost:8383/insertEntry/publishentry"/>
    </wsdl:port>
</wsdl:service>

I'll put the definitions of the messages here too, to see that the problem is not them, in fact:

EntryRequest:

<xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:au="http://soapadapter.goodbooze.marlo.com.au/entities/Entry"
    xmlns:ms="http://soapadapter.goodbooze.marlo.com.au/entities/entryRequest"
    targetNamespace="http://soapadapter.goodbooze.marlo.com.au/entities/entryRequest"
    elementFormDefault="qualified">
<xs:import namespace="http://soapadapter.goodbooze.marlo.com.au/entities/Entry"
           schemaLocation="entryDefinitions.xsd"/>
<xs:element name="entryRequest">
    <xs:complexType>
        <sequence>
            <xs:element name = "entry" type = "au:entryType"  minOccurs="1" maxOccurs="1"/>
        </sequence>
    </xs:complexType>
</xs:element>

EntryResponse:

<xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:au="http://soapadapter.goodbooze.marlo.com.au/entities/Entry"
    xmlns:ms="http://soapadapter.goodbooze.marlo.com.au/entities/entryResponse"
    targetNamespace="http://soapadapter.goodbooze.marlo.com.au/entities/entryResponse"
    elementFormDefault="qualified">
<xs:import namespace="http://soapadapter.goodbooze.marlo.com.au/entities/Entry"
            schemaLocation="entryDefinitions.xsd"/>
<xs:element name="entryResponse">
    <xs:complexType>
        <sequence>
            <xs:element name = "entryResponse" type = "xs:string"/>
        </sequence>
    </xs:complexType>
</xs:element>

SoapFault:

<xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:au="http://soapadapter.goodbooze.marlo.com.au/entities/Entry"
    xmlns:ms="http://soapadapter.goodbooze.marlo.com.au/entities/soapFaultMessage"
    targetNamespace="http://soapadapter.goodbooze.marlo.com.au/entities/soapFaultMessage"
    elementFormDefault="qualified">
<xs:import namespace="http://soapadapter.goodbooze.marlo.com.au/entities/Entry"
        schemaLocation="entryDefinitions.xsd"/>
<xs:element name="soapFaultMessage">
    <xs:complexType>
        <sequence>
            <xs:element name = "errorMessage" type = "au:errorMessageType"  />
        </sequence>
    </xs:complexType>
</xs:element>

And the xsd that defines the types:

<xs:complexType name = "productType">
    <xs:sequence>
        <xs:element name = "internalID" type="xs:int"  minOccurs="1" maxOccurs="1"/>
        <xs:element name = "name" type="xs:string"  minOccurs="1" maxOccurs="1"/>
    </xs:sequence>
</xs:complexType>

<xs:complexType name = "storeType">
    <xs:sequence>
        <xs:element name = "storeID" type = "xs:int"  minOccurs="1" maxOccurs="1"/>
        <xs:element name = "name" type = "xs:string"  minOccurs="1" maxOccurs="1"/>
    </xs:sequence>
</xs:complexType>

<xs:complexType name = "itemStoreOrderType">
    <xs:sequence>
        <xs:element name="quantity" type="xs:long"  minOccurs="1" maxOccurs="1"/>
        <xs:element name="product" type="au:productType" minOccurs="1" maxOccurs="1"/>
    </xs:sequence>
</xs:complexType>

<xs:complexType name = "storeOrderType">
    <xs:sequence>
        <xs:element name ="storeOrderID" type="xs:int"  minOccurs="1" maxOccurs="1"/>
        <xs:element name = "store" type="au:storeType" minOccurs="1" maxOccurs="1"/>
        <xs:element name = "itemStoreOrderList" type = "au:itemStoreOrderType" maxOccurs = "unbounded" minOccurs = "1"/>
    </xs:sequence>
</xs:complexType>

<xs:complexType name = "entryType">
    <xs:sequence>
        <xs:element name = "insertDate" type = "xs:string" />
        <xs:element name = "storeOrder" type = "au:storeOrderType" maxOccurs = "unbounded" minOccurs = "1"/>
    </xs:sequence>
</xs:complexType>

<xs:complexType name="errorMessageType">
    <xs:sequence>
        <xs:element name = "errorCode" type="xs:string" minOccurs="1" maxOccurs="1"/>
        <xs:element name = "errorCause" type="xs:string" minOccurs="1" maxOccurs="1"/>
    </xs:sequence>
</xs:complexType>

<xs:complexType name="successMessageType">
    <xs:sequence>
        <xs:element name = "successMessage" type="xs:string" fixed="DONE." minOccurs="1" maxOccurs="1"/>
    </xs:sequence>
</xs:complexType>

This is how I defined the routes. It basically sets the error handling, and if it does not, it transforms the input data, it passes to another endpoint and then processes a response:

onException(Exception.class)
            .log("${body}")
            .log(LoggingLevel.ERROR, "An error was found.")
            .process(new SOAPFaultProcessor())
            .handled(true);

    from("cxf:bean:insertEntry")
        .routeId("LegacySystemMessage")
        .log("${body}")
        .to("xquery:process/xquery/getListOfOrders.xq")
        .inOnly("jms:queue:orderManager")
        .process(new ResponseSucessProcessor())
        .log(LoggingLevel.INFO, "Response message: ${body}");

And the classes that the process call are very simple too

ResponseSuccessProcessor:

public class ResponseSucessProcessor implements Processor {

@Override
public void process(Exchange exchange) throws Exception {

    StringWriter writer = new StringWriter();
    EntryResponse response = new EntryResponse();
    response.setEntryResponse("Message received");

    JAXBContext jxb = JAXBContext.newInstance(EntryResponse.class);
    Marshaller m = jxb.createMarshaller();

    m.marshal(response, writer);
    exchange.getOut().setBody(writer.toString());
}

}

And to SOAPFaultProcessor:

public class SOAPFaultProcessor implements Processor {

@Override
public void process(Exchange exchange) throws Exception {

    Exception exception = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);

    SoapFault fault = new SoapFault(exception.getMessage(), SoapFault.FAULT_CODE_SERVER);

    SoapFaultMessage soapFaultMessage = new SoapFaultMessage();
    ErrorMessageType errorMessageType = new ErrorMessageType();

    errorMessageType.setErrorCode(fault.getCode());
    errorMessageType.setErrorCause("Something wrong happened");

    soapFaultMessage.setErrorMessage(errorMessageType);

    StringWriter writer = new StringWriter();
    JAXBContext jxb = JAXBContext.newInstance(SoapFaultMessage.class);
    Marshaller marshaller = jxb.createMarshaller();
    marshaller.marshal(soapFaultMessage, writer);

    exchange.getOut().setFault(true);
    exchange.getOut().setBody(writer.toString());

}

So, when I try to simulate the service using SOAPUI, it gives me the following error message

<faultstring>Part {http://soapadapter.goodbooze.marlo.com.au/services/EntryService}parameters should be of type au.com.marlo.goodbooze.soapadapter.entities.entryresponse.EntryResponse, not java.lang.String</faultstring>

The message implies that the WSDL settings are wrong, but I have checked several times and can not see anything that justifies this message. Could someone help me figure out what's causing this response? Thank you.

    
asked by anonymous 04.01.2018 / 14:04

2 answers

0
The problem was quite simple, it was only because my ResponseSucessProcessor was returning a String as a response, and what the wsdl was expecting was the direct EntryResponse object, not a conversion.

    
10.01.2018 / 17:07
0

It seems that the error comes from the attribute parts qie you are using in operation > bindings.                          

            <wsdl:operation name="postEntry">
                <soap:operation soapAction="action" style="document"/>

                <wsdl:input >
                    <soap:body use="literal" **parts="parameters"**/>
                </wsdl:input>
            ...

Try removing these parts="parameters".

    
07.01.2018 / 01:36