Java calls net webservice troubleshooting practical sharing

This article is reproduced from: http://blog.sina.com.cn/s/blog_4c925dca01014y3r.html
A few days ago, the company wanted to access a business function of a foreign company, and the other party was the web service generated by the provided net. When Atang used the wsdl2java command of cxf to generate the test code of the client, the following fault
occurred: WSDLToJava Error: Thrown by JAXB: undefined element declaration 's:schema'

 

Java calls net webservice troubleshooting practical sharing

So Ah Tang (Internet Time and Space) searched a lot of information on the Internet and continued to practice and explore, and finally found the following two solutions. I hope that the solution process and summary of Ah Tang (Internet Time and Space) can solve similar problems for other netizens. Signs and references.
The first way (still solved with cxf)
step1
Save  the content corresponding to http://test.payserv.net/Paygate/ccservice.asmx?WSDL  as ccservice.wsdl

 

Java calls net webservice troubleshooting practical sharing

It should be noted here that you can only save as ccservice.wsdl in the web page, you cannot simply copy the web page, paste it into a text file, and save it as  ccservice.wsdl , so that even after the following step2 , still gives an error

 

Java calls net webservice troubleshooting practical sharing

 

step2
First  replace the following content in the ccservice.wsdl file as follows
即将  <s:element ref="s:schema" /><s:any />  替换成  <s:any minOccurs="2" maxOccurs="2"/>

 

Java calls net webservice troubleshooting practical sharing

After doing this, running wsdl2java again reported the following error

 

Java calls net webservice troubleshooting practical sharing

After careful inspection and analysis by Ah Tang, it turns out that in the ccservice.wsdl file, there are two definitions of queryResponse  and  QueryResponse  . It may be that the webservice is not case-sensitive in the net, but when the client of the webservice is generated in java, it is It is case sensitive, so the above error will be reported. In response to this, Atang (Network Time and Space) changed the name of  QueryResponse to QueryResponse1 at that time , and changed all references to QueryResponse to QueryResponse1 in the ccservice.wsdl file . . Then run it again and everything is ok

 

Java calls net webservice troubleshooting practical sharing

Java calls net webservice troubleshooting practical sharing 

 

 

 

Atang summarizes

When using cxf's wsdl2java command to process webservices generated by net or other languages, if an error occurs, carefully observe the description of the error message, and make targeted modifications by thinking and querying network resources by yourself.

 

 

The second way (solved with axis's webservice framework)

From the test of Atang (network time and space), the client of websercie can be generated without any modification

 

Java calls net webservice troubleshooting practical sharing

 

However, the following jar packages of axis are required to ensure the normal operation of the client code of the webservice generated by axis

 

Java calls net webservice troubleshooting practical sharing

Atang summarizes

If you find that the wsdl2java command of cxf cannot be executed normally, you may wish to use other webservice frameworks such as axix to solve the problem and solve the problem from a different angle.

 

Calling method
Ccservice ccservice = new Ccservice();
CcserviceSoap ccserviceSoap = ccservice.getCcserviceSoap();
ccserviceSoap.query(parameter 1, parameter 2,...);

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326572596&siteId=291194637