我是网络服务的新手。我遇到了一些问题。 在服务器端我使用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());
谢谢。任何帮助将受到高度赞赏。
答案 0 :(得分:2)
似乎它只是一个无效的响应体,不是数学wsdl shema。无论是春天还是没有jax-ws抛出异常。它只是将无效数据解析为空列表而没有任何更改。
org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor
节省了我的一天
可能我必须调整jax-ws的日志记录以避免下次
答案 1 :(得分: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前缀。值得付出努力。