Hi,
I am able to invoke a webservice using a Standalone
java program. I am using the below command to invoke the web service.
java com.javasrc.webservices.age.AgeServiceClient -lhttp://localhost:8080/axis/services/AgeService "Siva" 33
Now if I write the whole code in a method I am not able to retreive the values into the
servlet. Can any please suggest me how to invoke a web service from a servlet/JSP. Please tell if there any sites for this.
Here is my Client code:
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
public class AgeServiceClient
{
public static void main(
String [] args)
{
try
{
Options options = new Options(args);
String endpointURL = options.getURL();
String name;
Integer age;
args = options.getRemainingArgs();
if ((args == null) || (args.length < 2))
{
name = "NoName";
age = new Integer( 0 );
}
else
{
name = args[ 0 ];
age = new Integer( args[ 1 ] );
}
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpointURL) );
call.setOperationName( new QName("http://age.webservices.javasrc.com", "age") );
call.addParameter( "arg1", XMLType.XSD_STRING,ParameterMode.IN);
call.addParameter( "arg2", XMLType.XSD_INT, ParameterMode.IN);
call.setReturnType( org.apache.axis.encoding.XMLType.XSD_STRING);
String ret = (String) call.invoke( new Object[]{name,age});
System.out.println("Age result : " + ret);
}
catch (Exception e)
{
System.err.println(e.toString());
}
}
}
Thanks in advance
Prashanth