Java开发WebServices传递pojo提示参数不匹配的问题

webservices服务用Java开发的时候,参数为基本数据类型是没有甚么问题的。

但是如果是传递pojo,也就是java对象,可能你会遇到参数不匹配的问题。

webservices接口暴露出来以后肯定是1个wsdl文件,看到网上很多文章说“webservices传递pojo的时候,提示参数不匹配,很多人解决方式是把接口和pojo放在1起就好用了。这个实际上是表象”

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://d.c.b.a/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="TestwsImpl1Service" targetNamespace="http://d.c.b.a/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://d.c.b.a/" elementFormDefault="unqualified" targetNamespace="http://d.c.b.a/" version="1.0">
<xs:element name="updatePerson" type="tns:updatePerson"/>
<xs:element name="updatePersonResponse" type="tns:updatePersonResponse"/>
<xs:complexType name="updatePerson">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="tns:person"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="person">
<xs:sequence>
<xs:element name="age" type="xs:int"/>
<xs:element minOccurs="0" name="name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="updatePersonResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="tns:person"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="updatePersonResponse">
<wsdl:part element="tns:updatePersonResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="updatePerson">
<wsdl:part element="tns:updatePerson" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:portType name="TestwsImpl1">
<wsdl:operation name="updatePerson">
<wsdl:input message="tns:updatePerson" name="updatePerson"></wsdl:input>
<wsdl:output message="tns:updatePersonResponse" name="updatePersonResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="TestwsImpl1ServiceSoapBinding" type="tns:TestwsImpl1">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="updatePerson">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="updatePerson">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="updatePersonResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TestwsImpl1Service">
<wsdl:port binding="tns:TestwsImpl1ServiceSoapBinding" name="TestwsImpl1Port">
<soap:address location="http://localhost:888/test1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

以上是我开发的1个webservices接口对应的wsdl文件, 文件中我的targetNamespace是

targetNamespace="http://d.c.b.a/"

也就是说 我的webservices服务真个person和targetNamespace不是1样的路径。

————————————————————————————————————————

我们再来开发1个客户端程序。

客户真个person路径为服务端targetNamespace是对应关系。

这类情况下,传递pojo才能调通。

总结:webservices服务真个pojo路径无所谓在这里,只要客户端pojo包路径和wsdl文件中targetNamespace对应,就能够调用通过。

网上说:客户端必须把pojo和接口声明放在1起的结论实际上是不对的。

波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!

波比源码 » Java开发WebServices传递pojo提示参数不匹配的问题

发表评论

Hi, 如果你对这款模板有疑问,可以跟我联系哦!

联系站长
赞助VIP 享更多特权,建议使用 QQ 登录
喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡