I am trying to access a SOAP1.2 webservice using Spring-ws. I have confirmed that the service is indeed 1.2
I am sending SOAP XML to the service using WebServiceTemplate. I have initialized the template with SaajSoapMessageFactory and have set the soap version to 1.2. I am getting a SOAPFaultClientException with the message " org.springframework.ws.soap.client.SoapFaultClient Exception: Unable to handle request without a valid action parameter. Please supply a valid soap action."
I looked in WireShark and found that SOAPAction is not being sent in the HTTP Header. If you see my Java Code, I have set the SOAPAction in the SoapActionCallBack and it still does not work. What am I doing wrong?
By the way I have ran the same XML using TCPMon and I am able to get the results back from Service, so I don't think it is any issue with the xml content.
Java Code:
Here is my spring config:Code:import java.io.StringReader; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.ws.WebServiceMessage; import org.springframework.ws.client.WebServiceIOException; import org.springframework.ws.client.core.WebServiceTemplate; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.client.SoapFaultClientException; import org.springframework.ws.soap.client.core.SoapActionCallback; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { // "classpath:NetworkSolution.xml" }) public class WebServiceClientTest { private static final String MESSAGE = "<?xml version=\"1.0\" encoding=\"utf-8\"?> " + "<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:urn=\"urn:networksolutions:apis\"> " + "................"; @Autowired private WebServiceTemplate webServiceTemplate; @Test // send to the configured default URI public void simpleSendAndReceive() { try{ StreamSource source = new StreamSource(new StringReader(MESSAGE)); StreamResult result = new StreamResult(System.out); SoapActionCallback actionCallBack = new SoapActionCallback("https://ecomapi.networksolutions.com/soapservice.asmx") { public void doWithMessage(WebServiceMessage msg) { SoapMessage smsg = (SoapMessage)msg; smsg.setSoapAction("http://networksolutions.com/ReadOrder"); } }; webServiceTemplate.sendSourceAndReceiveToResult( "https://ecomapi.networksolutions.com/soapservice.asmx", source, // new SoapActionCallback("http://networksolutions.com/ReadOrder"), actionCallBack, result); System.out.println(source.getInputStream().toString()); System.out.println(result.getWriter().toString()); }catch (SoapFaultClientException e) { System.out.println(e.getFaultCode()); System.out.println(e.getFaultStringOrReason()); System.out.println(e.fillInStackTrace().getLocalizedMessage()); } catch (WebServiceIOException we) { System.out.println(we.getRootCause()); } } }
Thanks,Code:<?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:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"> <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"> <property name="soapVersion"> <util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_12" /> </property> </bean> <bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate"> <constructor-arg ref="messageFactory" /> <property name="defaultUri" value="https://ecomapi.networksolutions.com/soapservice.asmx" /> <property name="messageSender"> <bean class="org.springframework.ws.transport.http.CommonsHttpMessageSender" /> </property> </bean> </beans>
Praveen


Reply With Quote