Please begging for help extremly URGENT
Damien Cummins <[email protected]> Mon, 28 Jul 2003 10:08:41 +0200
| Newsgroups | gmane.comp.java.enhydra.ksoap |
|---|---|
| Organization | CDS |
| Message-ID | <[email protected]> |
Hello,
I have this web service that i MUST call using a ksoap client I have tried
several approaches and no sucess. I'm now in a position where it is
absolutely necessary that this is done immediately it's extermely urgent!!!
I'am seriously at my wit's end so really need some kind of saviour could
somebody please write a simple client in ksoap to call this service
please please please !!!!!!!!!!!!
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.rpc.ParameterMode;
public class Sesame {
/**
* A local method which contains all the code to access the remote resolving
method
* @param name a name to resolve
* @return a result which has to be parsed to extract information
*/
public String getNameResolved(String name) {
String ret = null;
try {
// URL corresponding to the Web Service which will be called
String endpoint = "http://cdsws.u-strasbg.fr/axis/Sesame.jws";
// Name of the method which will be invoked
String method = "Sesame";
// Creates a Service object
Service service = new Service();
// Creates a Call object
Call call = (Call) service.createCall();
// Initialization of the call with the parameters
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName( method );
call.addParameter( "op1", XMLType.XSD_STRING, ParameterMode.IN );
call.setReturnType( XMLType.XSD_STRING );
// Invokes the remote method and gets a result
ret = (String)call.invoke( new Object [] { name });
}
catch (Exception e ) {System.out.println("getNameResolved : " + e);}
return ret;
}
public static void main(String [] args) throws Exception {
// Sesame object
Sesame sesame = new Sesame();
// Calls the the resolving method with the command line argument
String result = sesame.getNameResolved(args[0]);
if (result != null)
System.out.println("The result is : " + result);
else
System.out.println("Sorry but no result found ");
}
}
Damien Cummins