aspose file tools*
The moose likes Web Services and the fly likes calling asp webservice from tomcat 5 based app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "calling asp webservice from tomcat 5 based app" Watch "calling asp webservice from tomcat 5 based app" New topic
Author

calling asp webservice from tomcat 5 based app

Elias Ta
Greenhorn

Joined: Sep 29, 2008
Posts: 15
Hi,
I have a java web app running in Tomcat 5, I want to start calling webservices written in ASP .NET from the Java application.

What do I need (Do I need to install AXIS or SOAP ) ? and How do I do it ( and if you have a simple example) ?.

I have never done any webservices before...

Thanks in advance
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12825
    
    5
If the webservice you need to call is SOAP based and has a WSDL (Web Services Descriptive Langauge) document, you should be able to create a Java client with the AXIS2 toolkit. In theory, the language used to write the service should make no difference.

Wikipedia has a convenient summary of the role of WSDL.

The AXIS2 download is full of examples.

Bill
Elias Ta
Greenhorn

Joined: Sep 29, 2008
Posts: 15
Thanks Bill..
This is what I did and failed ( It won't even get to the first line in the try block) , can you please suggest anything? Thanks so much..

1. I downloaded Axis into my tomcat/webapps/axis
2. set my classpath as
C:\axis\axis-1_4\lib\axis.jar;C:\axis\axis-1_4\lib\axis-ant.jar;C:\axis\axis-1_4\lib\commons-discovery-0.2.jar;C:\axis\axis-1_4\lib\commons-logging-1.0.4.jar;C:\axis\axis-1_4\lib\jaxrpc.jar;C:\axis\axis-1_4\lib\saaj.jar;C:\axis\axis-1_4\lib\wsdl4j-1.5.1.jar;

3. Went through check list for proper installation and confirmed that I have all required classes found..

4. The webservice url is http://services.lpcorp.com/TestService/testservice.asmx

and I use the following client to call..

package com.servicelane.helpers;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;

import org.apache.log4j.Category;
public class AxisClient {

private static Category message;
public String getTestMath() {
String retString = "";
try {
message.info("about to call endpoint");
String endpoint = "http://services.lpcorp.com/TestService testservice.asmx";

Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName("TestMath");
Integer i1 = new Integer(5);
Integer i2 = new Integer(9);

Integer ret = (Integer) call.invoke( new Object[] { i1, i2 } );
retString = ret.toString();
} catch (Exception e) {
message.info("Exception in trying to getTestmath is :" + e);
}
return retString;

} //end of local method
} // end of class
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12825
    
    5
failed ( It won't even get to the first line in the try block) , can you please suggest anything?


No - Because you dont say what actually happened!

If you never got to the start of the try, how do you know getTestMath() was even called.
Elias Ta
Greenhorn

Joined: Sep 29, 2008
Posts: 15
Okay please help me with how to build a client for a webservice..
This is where I am
1. I downloaded Axis2 and went through with samples being able to deploy the services bla bla.. I didn't do anything but to follow the steps
2. I can't seem to understand building the client. They have five ways of doing it but I don't know what they are talking about..

Can you please give me a sample of client for a webservice that is on
http://services.lpcorp.com/TestService/testservice.asmx

I appreciate your help..
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42641
    
  65
I'd start by pointing Axis' wsdl2java tool at the WSDL of the web service you've deployed. That will create a number of Java classes that can be used to build a client. The Axis Quick Start Guide talks about how to use the tool.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling asp webservice from tomcat 5 based app