首页 > 解决方案 > Spring Webservice 客户端不返回任何数据

问题描述

要在我们的 Spring Web 应用程序中使用 Web 服务,我遵循以下说明:使用 JaxWsPortProxyFactoryBean 调用 Web 服务

我已经使用 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>

在另一个服务中,我注入服务并调用 web 服务:

@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 没有数据。

我应该采取什么方法来调试这个问题?任何帮助表示赞赏

标签: javaspringjax-ws

解决方案


推荐阅读