简体   繁体   中英

How to invoke a Web Service using Java

I am new to Web services. I need to invoke a web service whose definition is in http://api.search.live.net/search.wsdl . I need to do a search of any keyword by using this web service. I search on the net but could not find any solution. Any idea how to invoke the web service. I need to use Java.

Download axis2 .

After extracting it, under the bin folder there is a tool called wsdl2java, this is used to generate stubs from the WSDL that can communicate with the webservice.

A sample usage would be:

WSDL2Java -uri http://api.search.live.net/search.wsdl  -d xmlbeans -s

look here for more details on that tool.

Besides stubs it will also generate all the objects you need.

Here is a tutorial using axis2 and Eclipse IDE.

Take a look at http://ws.apache.org/ where you will find Axis2 which is probably what you are looking for.

Note that web-services are more generic term than WSDL and have evolved since WSDL was introduced to the point that most services today speak JSON and alike. See more here RESTEasy or Jersey?

I use intelliJ to generate the java code I need from a WSDL. You can then use this code to do SOAP calls.

Give it the WSDL and it will generate the code, some info can be found here: http://www.jetbrains.com/idea/webhelp/generating-wsdl-document-from-java-code.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM