You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by Rishi Khanna <ri...@yodlee.com> on 2001/04/27 01:15:11 UTC
Get me started
Hi,
I have the folowing codes in my client and server.
Client Code:
import java.io.*;
import java.net.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
import java.net.*;
import org.apache.soap.encoding.*;
class SoapTest{
public static void main(String args []){
Call call = new Call ();
Response resp = null;
SOAPMappingRegistry smr = call.getSOAPMappingRegistry();
call.setTargetObjectURI ("urn:SoapTest"); //Invoke Target
Function Filename
call.setMethodName ("plus"); //Invoke Method Name
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Vector params = new Vector ();
params.addElement (new Parameter("params1", double.class,new Double
(1.0), null));
params.addElement (new Parameter("params2", double.class,new Double
(2.0), null));
call.setParams (params);
String str = new
String("http://192.168.202.26:5791/servlet/org.apache.soap.server.http.RPCRo
uterServlet");
try{
URL url = new URL(str);
resp = call.invoke ( url,"");
if (resp.generatedFault ()) {
Fault fault = resp.getFault ();
System.out.println ("Ouch, the call failed: ");
System.out.println (" Fault Code = " + fault.getFaultCode
());
System.out.println (" Fault String = " +
fault.getFaultString ());
}
}catch(Exception e){
e.printStackTrace();
}
Parameter result = resp.getReturnValue();
System.out.println(result.getValue().toString());
}
}
Server Code:
import java.util.*;
public class SoapTest{
public Vector plus(Double d1,Double d2){
double d3 = 0.0;
d3 = d1.doubleValue() + d2.doubleValue();
Vector params = new Vector ();
params.addElement(new Double(d3));
return params;
}
}
I am getting the following error:
Ouch, the call failed:
Fault Code = SOAP-ENV:Server
Fault String = service 'urn:SoapTest' unknown
Rishi2
Exception in thread "main" java.lang.NullPointerException
at SoapTest.main(SoapTest.java:45)
Please help me what is wrong ?I am able to run the sample calculator
program.
--Rishi
Re: Get me started
Posted by Naggi Rao <na...@softhome.net>.
Simply means that you have not deployed the SoapTest
Delpoy it either thru the jsp page
or
by...
java org.apache.soap.server.ServiceManagerClient
http://localhost:port/rpcrouter deploy DeploymentDescriptor.xml
Cheers,
Naggi
----- Original Message -----
From: "Rishi Khanna" <ri...@yodlee.com>
To: <so...@xml.apache.org>
Sent: Thursday, April 26, 2001 4:15 PM
Subject: Get me started
> Hi,
>
> I have the folowing codes in my client and server.
>
>
> Client Code:
>
> import java.io.*;
> import java.net.*;
> import java.util.*;
> import java.awt.*;
> import java.awt.event.*;
> import org.apache.soap.util.xml.*;
> import org.apache.soap.*;
> import org.apache.soap.rpc.*;
> import java.net.*;
> import org.apache.soap.encoding.*;
>
>
> class SoapTest{
> public static void main(String args []){
> Call call = new Call ();
>
>
> Response resp = null;
> SOAPMappingRegistry smr = call.getSOAPMappingRegistry();
> call.setTargetObjectURI ("urn:SoapTest"); //Invoke Target
> Function Filename
> call.setMethodName ("plus"); //Invoke Method Name
> call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
> Vector params = new Vector ();
> params.addElement (new Parameter("params1", double.class,new Double
> (1.0), null));
> params.addElement (new Parameter("params2", double.class,new Double
> (2.0), null));
> call.setParams (params);
> String str = new
>
String("http://192.168.202.26:5791/servlet/org.apache.soap.server.http.RPCRo
> uterServlet");
> try{
> URL url = new URL(str);
> resp = call.invoke ( url,"");
> if (resp.generatedFault ()) {
> Fault fault = resp.getFault ();
> System.out.println ("Ouch, the call failed: ");
> System.out.println (" Fault Code = " + fault.getFaultCode
> ());
> System.out.println (" Fault String = " +
> fault.getFaultString ());
> }
>
> }catch(Exception e){
> e.printStackTrace();
> }
> Parameter result = resp.getReturnValue();
> System.out.println(result.getValue().toString());
> }
> }
>
>
>
> Server Code:
>
> import java.util.*;
>
> public class SoapTest{
> public Vector plus(Double d1,Double d2){
> double d3 = 0.0;
> d3 = d1.doubleValue() + d2.doubleValue();
> Vector params = new Vector ();
> params.addElement(new Double(d3));
> return params;
> }
> }
>
>
> I am getting the following error:
>
> Ouch, the call failed:
> Fault Code = SOAP-ENV:Server
> Fault String = service 'urn:SoapTest' unknown
> Rishi2
> Exception in thread "main" java.lang.NullPointerException
> at SoapTest.main(SoapTest.java:45)
>
>
>
> Please help me what is wrong ?I am able to run the sample calculator
> program.
>
> --Rishi
>
>