Definition of WSDL raising exception

Asked

Viewed 106 times

0

Hello, I’ve been trying for a few days to define a wsdl of a component that uses SOAP for a SOA project that mixes several types of services, integrating them with Camel. But I’m caught in a problem that I don’t see the point in the answer he gives me, which I believe is 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’m going to put the message settings here as well, 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>

That’s the way I set the routes. It basically defines the handling of errors, and, if there is no, transforms the input, forwards to another endpoint and then processes a Sponse:

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 calls 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 the 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());

}

Thus, 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 suggests that the WSDL definitions are wrong, but I have checked several times and I can’t understand anything that justifies this message. Can anyone help me understand what is causing this response? Thank you.

2 answers

0

It seems that the error is coming from the attributo Parts qie is 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 this Parts="Parameters".

0


The problem was pretty simple, it was just because my Responsesucessprocessor was returning a String as an answer, and what wsdl was waiting for was the direct Entryresponse object, not a conversion.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.