'org.springframework.ws.soap.client.SoapFaultClientException: 400200

I was trying to develop a webservice client using spring webservicetemplate. I am newbee to both spring and webservices. I am badly struck with this error. I am getting soap fault with the below exception, if i remove the handler from the marshallandsend call it gives me 404 Not found error :

org.springframework.ws.soap.client.SoapFaultClientException: 400200
at com.xaptum.commandrouter.CheckTest.theSoapActionName(CheckTest.java:99)
at com.xaptum.router.SendSmsTest.main(SendSmsTest.java:126)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

The error code seems weird. I have never come across such error code. Any help on this is much appreciated.

The XML bean definitions:

<?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:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema
oxm/spring-oxm-1.5.xsd">

 <bean id="wsSecurityInterceptor"
 class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor">
 <property name="policyConfiguration" value="classpath:securityPolicy.xml"/>
 <property name="callbackHandlers" ref="passwordValidationHandler">
 </property>
 </bean>

<bean id="passwordValidationHandler"
class="org.springframework.ws.soap.security.xwss.callback
.SimplePasswordValidationCallbackHa
property name="users">
<props >
<prop key="quodientatt">quodientm2m!</prop>
</props>
</property>

<bean id="messageFactory" 
class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" />
<bean id="messageSender"
class="org.springframework.ws.transport.http.CommonsHttpMessageSender" />

<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>com.jasperwireless.api.ws.schema.SendSMSResponse</value>
</list>
</property>
</bean>
<bean id="unmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>com.jasperwireless.api.ws.schema.SendSMSRequest</value>
</list>
</property>
</bean>

<bean id="webServiceTemplate" 
class="org.springframework.ws.client.core.WebServiceTemplate">
<property name="defaultUri" value="https://api.jasperwireless.com/ws/service/Sms" />
<property name="Marshaller" ref="marshaller" />
<property name="unmarshaller" ref="unmarshaller" />
<property name="messageSender" ref="messageSender" />
<property name="interceptors" ref="wsSecurityInterceptor" />
</bean>
<bean id="Check" class="com.xaptum.commandrouter.CheckTest">
 <property name="webServiceTemplate" ref="webServiceTemplate" /> 

The test class is

setSoapAction("http://api.jasperwireless.com/ws/service/sms/SendSMS");
    SendSMSRequest request=new ObjectFactory().createSendSMSRequest();
    System.out.println("Created the objet");

    request.setSentToIccid("89011704258000373997");
    request.setMessageText("MEssage Text");
    request.setMessageTextEncoding("LITERAL");
    request.setVersion("1.0");
    request.setLicenseKey("2ac997b0-bab3-4203-b8ba-e415a6e0dabd");
    request.setMessageId("");
ApplicationContext ctx = new ClassPathXmlApplicationContext("Client-Config.xml");

    CheckTest client = (CheckTest) ctx.getBean("Check");

WebServiceTemplate webServiceTemplate=(WebServiceTemplate) 
ctx.getBean("webServiceTemplate");

    security.setSecureRequest(true);

SendSMSResponse response = (SendSMSResponse ) 
webServiceTemplate.marshalSendAndReceive(request,new WebServiceMessageCallback() {
    public void doWithMessage(WebServiceMessage message) {
        ((SoapMessage)message).setSoapAction("http://api.jasperwireless.com/ws/service  
/sms/SendSMS");
    }
 });
return (Object) response;
}


Solution 1:[1]

Unfortunately I can't help you with Spring, however I would like to make couple of suggestions/approaches.

1) It looks like you are getting error 400200. According to Jasper documentation: https://api.jasperwireless.com/provision/secure/apidoc/ it is a authentication issue:

400200=Security validation error. Your username or password is incorrect.

2) Print out resolving SOAP request and use SoapUI to test it. It helped me a lot!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MeIr