Hi All,
I am developing a web application which calls a web-service that provides HttpBinding to implement it. So, I thought of using <http:outboundgateway> in my config file.
But, when I call the service I am getting this error -
"Caused by: org.springframework.web.client.HttpClientErrorExce ption: 415 Cannot process the message because the content type 'text/plain;charset=UTF-8' was not the expected type 'text/xml; charset=utf-8'."
This is my config file.
Also, this is my class calling the service.Code:<?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/integration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:int="http://www.springframework.org/schema/integration" xmlns:stream="http://www.springframework.org/schema/integration/stream" xmlns:ws="http://www.springframework.org/schema/integration/ws" xmlns:int-http="http://www.springframework.org/schema/integration/http" 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 http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd"> <int-http:outbound-gateway id="example" request-channel="input_userdetails" url="http://xxxxxxxx/AuthenticationService/Service1.svc?wsdl" http-method="POST" expected-response-type="java.lang.String" charset="UTF-8" reply-channel="output_sessiontoken"/> <!-- The response from the service is logged to the console. --> <stream:stdout-channel-adapter id="output_sessiontoken" /> </beans:beans>
The error here is that, what ever the input I am giving to the URL is going in a text/plain format. But, the service is expecting a text/xml format. So, can any one provide me information of where to change/append in my code so, that the xml I am sending to the service will be an XML instead of plain text.Code:public class UserSessionID_RiskMaster { public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("blog/authenticate-config.xml"); ChannelResolver channelResolver = new BeanFactoryChannelResolver(context); // Compose the XML message according to the server's schema String requestXml = "<GetUserSessionID>" + " <struserInfo>" + " <Message><Call><Function>LoginAdaptor.Authorization</Function>" + " </Call><Document><Authorization><UserInfo><UserName>csc</UserName>" + " <DSNName>RMXR7_MOBILE_FEB16</DSNName</UserInfo></Authorization>" + " </Document></Message>" + " </struserInfo> " + "</GetUserSessionID>"; // Create the Message object Message<String> message = MessageBuilder.withPayload(requestXml).build(); // Send the Message to the handler's input channel MessageChannel channel = channelResolver .resolveChannelName("input_userdetails"); System.out.println("Headers : " + message.getHeaders()); channel.send(message); } }
Awaiting for some help as it is really necessary.
Thanks in Advance.
Regards,
Avinash Munaga


Reply With Quote

