2

我是网络服务的新手。我遇到了一些问题。在服务器端,我使用的是 spring-ws。在客户端,我使用的是 jax-ws。使用 wsimport 工具,我根据我的 wsdl 生成了 java 类。

一切正常,但由于某种原因 jax-ws 无法正确解析数组和列表,所有列表都是空的

我绝对确定,该响应是正确的,用soapui对其进行了测试,而且我正在使用日志拦截器来记录输出响应。

以下是回复片段

反应看起来像

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <firstElementResponse>
         <name>hello world text</name>
         <name>hello world text</name>
         <name>hello world text</name>
      </firstElementResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

和wsdl的片段

<xs:complexType name="sayHelloResponseType">
  <xs:sequence>
    <xs:element maxOccurs="unbounded" minOccurs="0" name="name" type="xs:string"/>
  </xs:sequence>
</xs:complexType>

要生成客户端代码,我使用 wsimport。

SayHelloResponseType resp = serv.sayHello(r);
List<String> name = resp.getName();
System.out.println(name.size());

谢谢你。任何帮助将不胜感激。

4

2 回答 2

2

似乎它只是一个无效的响应体,而不是数学 wsdl shema。spring-ws 和 jax-ws 都不会抛出异常。它只是将无效数据解析为空列表而没有任何警告。

org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor拯救了我的一天

可能我必须调整 jax-ws 的日志记录以避免下次出现

于 2010-08-30T16:51:17.830 回答
0

我刚刚在How can I handle Castor unmarshaling of SOAP messages when the namespace is defined inside the operation tag?中回答了一个类似的问题?- 如果您使用的是 Spring-WS,那么您正在编写合同优先的 Web 服务,因此请确保您确实确定了该合同。将所有元素放在命名空间中,确保 XSD 架构期望元素是合格的,并在 Castor 映射中声明 ns-uri 和 ns-prefixes。这是值得的。

于 2011-02-16T01:02:37.030 回答