Total Pageviews

2010/01/29

Access .Net Web Services via Java Web Services Client


Scenario


Implementation Steps

Create a simple web service via Visual Studio 2008

1. Choose ASP.Net Web Srvice Application


2. Write a HelloWorld method which accept one String paramter, and will return "Hello~"+name.



As you run this asmx file, you will see this page:


If I filled in Albert and submit. I will get "Hello~Albert" in the next page.


You can use this link (http://localhost:3936/Service1.asmx?wsdl) to get its WSDL page.




Build Java client via Eclipse

1. Create a Dynamic Web Project


2. Given a project name and set target runtime. Click Next.


3. Click Next


4. Click Finish. Then you had finished the Dynamic Web Project creation.


5. Create a Web Service Client.


6. Fill in WSDL url link and click Next.


7. Click Finish.


8. Then Eclipse will create these Java classes automatically. (Except TestClient.java)





9. Create a standalone Java


10. Make good use of the proxy class which generate by eclipse automatically.


Run this Java class we mentioned above, you can see "helloMsg=Hello~Albert Guo" in your Eclipse console

No comments: