Hi Balaji,
It seems you have knowledge on soap.
Hi,
I have written a simple web service:
public class SoapService extends Object {
/** Creates new SoapService */
public SoapService() {
}
/** This is the SOAP exposes method
*/
public
String sayGreeting(String name)
{
return "Hello "+name;
}
}
I have written an soap.xml file:
<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
id="urn:greetingService">
<isd rovider type="java" scope="Request" methods="sayGreeting">
<isd:
java class="SoapService" static="false"/>
</isd rovider>
</isd:service>
I have deployed this service in
Tomcat:
java org.apache.soap.server.ServiceManagerClient
http://localhost:8080/soap/servlet/rpcrouter deploy soap.xml
It is deplyed also.
I have written a SOAP client:
public class ClientClass {
public static void main(String args[])
{
String urlString = args[0];
String name = args[1];
// build a Call object
Call call = new Call();
call.setTargetObjectURI("urn:greetingService");
call.setMethodName("sayGreeting");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
//creating a parameter list
Vector params = new Vector();
params.addElement(new Parameter("name", String.class, name,null));
// adding the parameter(s) to the Call object
call.setParams(params);
// invoke the soap method
Response res =null;
try {
res= call.invoke(new URL(urlString), "");
if( res.generatedFault()==false)
{
Parameter retValue = res.getReturnValue();
Object value = retValue.getValue();
System.out.println(value);
}else
{
System.out.println("The faulty is: "+res.getFault().getFaultString());
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SOAPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
When I run this client:
java clientclass
http://localhost:8080/soap/servlet/rpcrouter yourname
It gives me the error:
Unable to resolve target object: SoapService
Why?
Any thoughts?
Guru