简体   繁体   中英

Create a web service client in JAVA to access method from WSDL (w.Eclipse)

Completely new bee in web services.

I am having the url as:

http://abc.xyz.com/straw/api/?wsdl  

and method:

$result= $client->call($session, "catalog_product.list");   

This is what I have tried:

  1. Created a new JAVA project from Eclipse wizard.

  2. r click on the project navigate to web service-> web service client.

  3. Give the service definition http://abc.xyz.com/straw/api/?wsdl

  4. in configuration:

    • (a) server runtime:tomcat v7.0 server
    • (b) webservice runtime:apache axis
  5. Choose test client from slider ( I have also tried develop client a bit confuse,as I have to create client much confused )

  6. Click on finish.

As a result I found web service test client browser with some method, input and result. Also I got some JAVA file in my resources folder:

Mage_Api_Model_Server_HandlerBindingStub  
Mage_Api_Model_Server_HandlerPortType  
Mage_Api_Model_Server_HandlerPortTypeProxy  
MagentoService  
MagentoServiceLocator

Are these source files are created by client?

I am not able to find method name...

$result= $client->call($session, "catalog_product.list");

...in any of the above JAVA files.

What I have to do to create a web service client???

What is expected from me as a deliverable (are these JAVA files in source folder).

Or do I have to write a JAVA project to access the web service's method

$result= $client->call($session, "catalog_product.list");

Like this tutorial:

What is my deliverable for "create a web service client to access method mentioned of below wsdl."

Sorry for my stupidity as I don't know even what to be output/ deliverable.

Any guidance? Thanks!

Yes, what you've done in fact is told Eclipse that you'd want to create all the necessary classes such that you'll be able to make client calls to the web-service from Java. Now, I tried doing the same thing you did, to see what Eclipse generates, but unfortunatelly (at least for me) the wsdl address you gave doesn't work. I tried it however with a different wsdl, and I got some similar files generated by Eclipse.

Basically what Eclipse does there is:

  • it creates model classes that represent the (XML) data passed between client and server when you make a call to the web service using the generated client. These classes are, in your case, the ones which are just plain Java beans (in this context they have basic names, without any suffixes such as "_HanddlerXXX" or "Service" (I think you didn't list those here, or your service is very simple and it uses JDK classes as model classes such as String, Integer etc).
  • it also creates a Java interface that represent the web-service operations endpoint that are declared in the WSDL: this would be the "MagentoService", which has methods corresponding to the web-serviec operations endpoint (they return objects representing those endpoints
  • finally "Mage_Api_Model_Server_HandlerPortType" represent an web-service end-point and it offers methods correspondign to that end-point's operations. This interface you must implement with your desired logic and use that implementation to actually send request to your web-service

Now there's a lot of web-service and SOAP jargon here, not to mention a pretty involved framework for dealing with web-services in Java, namely Axis. My recommandations really is to read (at least the first 2 chapters from) the following book:

http://www.amazon.fr/Developing-Web-Services-Apache-Axis2/dp/0557254329/ref=sr_1_1?ie=UTF8&qid=1319032081&sr=8-1

it's excellent for sarting you up with the basic concepts of soap and rest web services, it has great examples from basic to involved of how to implement those notions in java using CXF and Axis2, and how to do this using Eclipse, it's just a great beginner book for what you're doing here.

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