要在Spring Web应用程序中使用Web服务,请按照以下说明操作:Calling web service with JaxWsPortProxyFactoryBean
我使用wsimport生成客户端类,我可以在命令行客户端中使用这些类。一切正常。
public static void main(String[] args) {
OrderServiceRequest req = new OrderServiceRequest()
// set fields
req.setLoginId('test');
ProfileService profileService = new ProfileService();
ProfileSoap port = profileService.getProfileSoap12();
OrderServiceResponse response = port.orderServiceRequest(req);
System.out.println("ErrorCode=" + response.getErrorCode());
}
我使用生成的类在Spring中实现一个服务。 我将服务配置为Spring Bean:
<bean id="myService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
<property name="serviceInterface" value="my.package.name.ProfileSoap" />
<property name="wsdlDocumentUrl" value="http://localhost:9999/connector/MyWebService?wsdl" />
<property name="namespaceUri" value="http://url.to.namespace" />
<property name="serviceName" value="ProfileService" />
<property name="endpointAddress" value="http://localhost:9999/connector/MyWebService" />
</bean>
在另一个服务中,我注入服务并调用webservice:
@Autowired
@Qualifier("myService")
ProfileSoap myService;
OrderServiceRequest req = new OrderServiceRequest();
req.setLoginId("12345");
req.setPassword("test");
req.setEAN("9783864905254");
// Request
OrderServiceResponse response = myService.orderServiceRequest(req);
// all fields of the response are null!
System.out.println(response.getErrorCode());
使用Eclipse中的TCP-Monitor,我可以看到响应返回正确的数据,但服务中的Response-Object没有数据。
我应该采取什么方法来调试此问题?任何帮助表示赞赏