我试图使用spring webservicetemplate开发一个webservice客户端。我是spring和webservices的新手。我被这个错误深深地震撼了。我得到了soap错误,下面的异常,如果我从marshallandsend调用中删除处理程序,它会给我404未找到错误:
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)
错误代码看起来很奇怪。我从来没有遇到过这样的错误代码。非常感谢对此的任何帮助。XML
Bean定义:
<?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" />
测试类为
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;
}
1条答案
按热度按时间qncylg1j1#
不幸的是,我不能帮助你与Spring,但我想提出一些建议/方法。
1)您似乎收到错误400200。根据碧玉文档:https://api.jasperwireless.com/provision/secure/apidoc/这是一个身份验证问题:
400200=安全验证错误。您的用户名或密码不正确。
2)打印出解析SOAP请求并使用SoapUI进行测试。这对我帮助很大!