Olá, venho há uns dias tentando definir um wsdl de um componente que utiliza SOAP para um projeto SOA que mistura diversos tipos de serviços, integrando-os com camel. Porém estou travado num problema que não vejo sentido na resposta que ele me dá, que acredito ser puramente da definição do serviço.
Esse é o meu 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>
Vou pôr as definições das mensagens aqui também, para verem que o problema não é elas, de fato:
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>
E o xsd que define os tipos:
<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>
Essa é a forma que fiz a definição das rotas. Ela basicamente define o tratamento dos erros, e, caso não haja, transforma o dado de entrada, repassa para outro endpoint e então processa um 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}");
E as classes que o process chamam são bem simples também
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());
}
}
E a 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());
}
Dessa forma, quando tento simular o serviço utilizando o SOAPUI, ele me dá a seguinte mensagem de erro
<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>
A mensagem dá a entender que as definições do WSDL está errada, mas já chequei várias vezes e não consigo perceber nada que justifique essa mensagem. Será que alguém consegueria me ajudar a perceber o que é que está ocasionando essa resposta? Obrigado.