Reputation: 2296
I set up a mock SOAP service in SoapUI following the guide here. When executing the CurrencyConvertorSoap12 Request 1 within SoapUI, I get the appropriate response:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://www.webserviceX.NET/">
<soap:Header/>
<soap:Body>
<web:ConversionRateResponse>
<web:ConversionRateResult>2.34</web:ConversionRateResult>
</web:ConversionRateResponse>
</soap:Body>
</soap:Envelope>
Now I want to test it using the Spring Integration web service outbound gateway.
I set up a web service test (the String requestXML
below is the same XML request in SoapUI):
@Test
public void webServiceTest() {
AbstractApplicationContext context = new ClassPathXmlApplicationContext("Context.xml");
DestinationResolver<MessageChannel> channelResolver = new BeanFactoryChannelResolver(context);
String requestXml = "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:web=\"http://www.webserviceX.NET/\">"
+ "<soap:Header/>"
+ "<soap:Body>"
+ "<web:ConversionRate>"
+ "<web:FromCurrency>?</web:FromCurrency>"
+ "<web:ToCurrency>?</web:ToCurrency>"
+ "</web:ConversionRate>"
+ "</soap:Body>"
+ "</soap:Envelope>";
Message<String> message = MessageBuilder.withPayload(requestXml).build();
MessageChannel channel = channelResolver.resolveDestination("wsInChannel");
channel.send(message);
}
Context.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-stream="http://www.springframework.org/schema/integration/stream"
xmlns:int-ws="http://www.springframework.org/schema/integration/ws"
xmlns:int-ftp="http://www.springframework.org/schema/integration/ftp"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/stream
http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
http://www.springframework.org/schema/integration/ws
http://www.springframework.org/schema/integration/ws/spring-integration-ws.xsd">
<int:channel id="wsInChannel"/>
<int:chain input-channel="wsInChannel" output-channel="stdoutChannel">
<int-ws:header-enricher>
<int-ws:soap-action value="http://www.webserviceX.NET/ConversionRate"/>
</int-ws:header-enricher>
<int-ws:outbound-gateway uri="http://localhost:8088/mockCurrencyConvertorSoap12"/>
</int:chain>
<int:channel id="stdoutChannel"/>
<int-stream:stdout-channel-adapter
id="consumer" channel="stdoutChannel" append-newline="true" />
</beans>
When I run the test, I get this error in SoapUI:
Thu Jun 09 11:50:21 EDT 2016:ERROR:An error occurred [Missing operation for soapAction [http://www.webserviceX.NET/ConversionRate] and body element [{http://www.w3.org/2003/05/soap-envelope}Envelope] with SOAP Version [SOAP 1.1]], see error log for details
What am I doing wrong?
Upvotes: 1
Views: 1175
Reputation: 121427
and body element [{http://www.w3.org/2003/05/soap-envelope}Envelope]
But you send the whole SOAP Envelope
, not just Body
as it requests.
So, your requestXml
must be like:
"<web:ConversionRate xmlns:web=\"http://www.webserviceX.NET/\">"
+ "<web:FromCurrency>?</web:FromCurrency>"
+ "<web:ToCurrency>?</web:ToCurrency>"
+ "</web:ConversionRate>"
And don't forget to replace ?
with an appropriate currencies :-)
Upvotes: 2