Calling a .NET C# Web Service with a Java/JSP Client

Netbeans and Apache Tomcat are used in this example to make a JSP client with the help of Apache SOAP toolkit (http://axis.apache.org/axis/). Assumption here is that you are bit familiar with JSP and NetBeans. Also, Apache Xerces (http://xerces.apache.org/) is used by the Java Client. The following jars are needed to run the Java Client successfully.

a)    activation.jar
b)    mailapi.jar (version 1.3 or later)
c)    soap.jar (version 2.1 or later)
d)    xercesImpl.jar (version 2.1.1 or later)
e)    xml-apis.jar (should come bundled with the Apache Xerces download)

  1. Click on File–>New Project –>Choose “Java Web” –>Web Application07-CreateNewNetBeansWebApp
  2. Provide a Project Name and Location08-NameNetBeansJavaWebApp
  3. Set up Server Settings and then click on “Next”09-PickJavaWebAppServer
  4. Disregard a Web App Framework for this tutorial and click on “Finish”10-DeclineFrameworkSelectionAndFinish
  5. Right click “Source Packages” and select “New”  Java Package11-newjavaPackage
  6. Name the package and click on “Finish”12-NameNewJavaPackage
  7. Reviewing our Java Client Web Application, the directory structure should look similar to this:13-JavaClientProjectStructure
  8. Right click the Java Web App project and select “Properties” from the menu14-JavaProjectProperties
  9. In the Project Properties window select “Libraries”. Click on “Add JAR/Folder” button15-Properties-Libraries
  10. Add activation.jar, mailapi.jar, soap.jar, xercesImpl.jar, and xml-apis Libraries to the Project16-AddTheWebServiceClientJarFiles
  11. Right click the JavaClient Project and select “New” –> Web Service Client…17-CreateNewWebServiceClient
  12. Configure the Web Service Client by Adding a WSDL URL (From .Net Web Service Step #7, paste the copied URL into the “New Web Service Client” WSDL URL field. Also, specify the package we created earlier to contain the generated java artifacts that will be created.18-ConfigureWebServiceClient
  13. After clicking on “Finish”, NetBeans will output information regarding the generated java artifacts. Aim for a “BUILD SUCCESSFUL” message19-NewWebServiceClientOutput
  14. Now that our Web Service Client has been created, go to the default NetBeans Java Client Web Application start page (index.jsp in this example) and right click within thetag. Select “Web Service Client Resources” –> Call Web Service Operation…20-CreateCallWebServiceOperation
  15. Select the appropriate Web Service. Here we will go with “WebService” –> WebServiceSoap –> HelloWorld21-SelectWebServiceOperationMethod
  16. After clicking “OK”, NetBeans will auto-generate a snippet of code and inject that code within the jsp file.22-WebServiceOperationCodeInjection
  17. Running the Java Client will result in a successful call to the ASP .NET C# Web Service that we constructed earlier. One can see that the Result string matches the return value of the HelloWorld() method of the ASP .NET Web Service23-RunNetBeansJavaClient
  18. The DotNetWebService.HelloWorld() Web Method returns the string value that the Java Client Web App did. Great work!24-MatchingDotNetAspWebServiceCode

This concludes the 2012 ASP .NET C# Web Service to Java Client consumption tutorial. May your Objects, Access, and Protocols be Simple and may your Web Services be RESTful for the next episode.

Advertisements

About javaclaus

Java Programmer, Code master, mountain biker, snowboarder, etc.
This entry was posted in Java, Tomcat, Web Services and tagged , , , , , . Bookmark the permalink.

3 Responses to Calling a .NET C# Web Service with a Java/JSP Client

  1. Noémio Dória says:

    Links are dead..

  2. javaclaus says:

    Noemio:
    Thanks for the heads up. I have updated the Apache SOAP toolkit link to point towards the Apache Axis site.

  3. ramesh says:

    can we do resume parsing by this

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s