Java Development webservices pass Pojo hint parameter mismatch problem

Source: Internet
Author: User

When WebServices services are developed in Java, there is no problem with the parameters as basic data types.

However, if you are passing Pojo, which is the Java object, you may encounter problems with parameter mismatches.


WebServices interface is definitely a WSDL file, see a lot of articles on the internet said "WebServices pass Pojo, prompt parameters do not match, a lot of people solve the way is to put the interface and Pojo together on the easy to use." This is actually a representation.

This XML file does does appear to has 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:o Utput></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>

The above is a webservices interface corresponding to the WSDL file I developed, the file of my targetnamespace is
Targetnamespace= "http://d.c.b.a/"


In other words, the person and targetnamespace on my webservices server are not the same path.


--------------------------------------------------------------------------------------------------------------- ---------


Let's develop a client program.



The client's person path is the targetnamespace of the service-side.


In this case, the pass-through Pojo can be transferred.


Summary: WebServices server Pojo path does not matter here, as long as the client Pojo package path and the WSDL file targetnamespace corresponding, it can be called through.


The conclusion that the client must put together the Pojo and the interface declaration is actually wrong.

Java Development webservices pass Pojo hint parameter mismatch problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.