2006-09-25 11:30:19 UTC
Hi,
I am trying invoke getSampleStruct method of mySampleService in samples in following manner:
public void doIt()
{
// get configuration
SoapConfig sc = new SoapConfig();
// set the actor for fault messages
sc.setActor("/sample/client");
// prepare a call
RPCCall call = new RPCCall( /* SoapConfig */ sc,
/* namespace */ "urn:mySampleService",
/* method */ "getSampleStruct");
// set parameters
try {
SampleStruct sampleStruct=new SampleStruct();
sampleStruct.myName="hello";
sampleStruct.aNumber=0;
sampleStruct.aLongNumber=23;
sampleStruct.trueOrFalse=true;
sampleStruct.breakIt=23.5;
call.setParameter("struct",sampleStruct,samples.SampleStruct.class);
// call.setParameter( /* name */ "mystring",
// /* value */ "sample",
// /* type */ String.class);
// call.setParameter( /* name */ "count",
// /* value */ new Integer(5),
// /* type */ int.class);
// execute call (via HTTP)
SoapHttpClient shc = new SoapHttpClient(sc);
Envelope answer = shc.invokeHTTP(
/* server */ new URL("
http://localhost:8080/...."),
/* SOAPAction*/ "",
/* envelope */ call.getEnvelope());
// check for a fault message
if(answer.hasFault()) {
Fault f = answer.getFault();
System.out.println("Faultcode: " + f.getFaultcode());
System.out.println("Faultstring: " + f.getFaultstring());
System.out.println("Faultactor: " + f.getFaultactor());
return;
}
// get the results
ParamBag p = call.getResults(answer);
// display the results
for(int i=0; i<p.size(); i++) {
System.out.print(p.getName(i) + "\t");
System.out.print(p.getType(i).getName() + "\t");
System.out.print(p.getValue(i) + "\n");
}
// If we know, the first return value is a string ...
// String result = (String) p.getValue(0);
// System.out.println("Result: " + result);
}
catch(Exception e) {
System.out.println("Exception: " + e);
e.printStackTrace();
}
}
But getting exception
/////////////////////////////////////////////////
Exception: de.fmui.spheon.jsoap.SoapException: [Could not encode Parameter 'struct': java.lang.NullPointerException]
de.fmui.spheon.jsoap.SoapException: [Could not encode Parameter 'struct': java.lang.NullPointerException]
at de.fmui.spheon.jsoap.SoapConfig.getEncEntry(Unknown Source)
at de.fmui.spheon.jsoap.SoapConfig.getEncEntry(Unknown Source)
at de.fmui.spheon.jsoap.ParamBag.setChildren(Unknown Source)
at de.fmui.spheon.jsoap.RPCCall.getEnvelope(Unknown Source)
at samples.SampleClient.doIt(SampleClient.java:59)
at samples.SampleClient.<init>(SampleClient.java:21)
at samples.SampleClient.main(SampleClient.java:93)
/////////////////////////////////////////////////
I cant understand why this error occuring.I have successfullly called other multi,sum,div methods of service.Anything missed or wrong?
Thanks,
Nancy