I tried integrating the code below that you suggested, but my
compiler isn't recognizing Hashtable ("cannot resolve symbol").
As to
your question about where the NPE occurs: It is occuring when I reference the
return value. But I don't know for sure that the line that does the
result.getValue() line is working properly also.
Below is the code for my
client.
package mypackage.io;
import java.net.*;
import
org.apache.soap.*;
import org.apache.soap.rpc.*;
public class
GetCountApp {
public static void
main(String[] args) throws
Exception
{
URL url = "" URL("http://localhost:8080/soap/servlet/rpcrouter");
Call call = new
Call();
call.setTargetObjectURI("urn:CallCounterService");
call.setMethodName("getCount");
try
{
Response resp = call.invoke(url,
"");
Parameter ret =
resp.getReturnValue();
Object value = ret.getValue(); <-- This is the line that is returning the
NPE
System.out.println("Result is " +
value);
}
catch (SOAPException
e)
{
System.err.println("Caught
SOAPException (" + e.getFaultCode() + "): " +
e.getMessage());
}
}
}
-----Original
Message-----
From: Scott Nichol [mailto:[EMAIL PROTECTED]]
Sent:
Tuesday, August 05, 2003 2:21 PM
To: [EMAIL PROTECTED]
Subject: Re:
SOAP getValue() returns NULL
Handling the return from a call is
typically done like:
//
Invoke the call and handle the
response.
Response resp =
call.invoke(url, "");
if
(resp.generatedFault())
{
Fault
fault =
resp.getFault();
System.err.println("Generated fault: " +
fault);
} else
{
Parameter result =
resp.getReturnValue();
Hashtable hash = (Hashtable)
result.getValue();
System.out.println("keys: " +
hash.get("keys"));
System.out.println("values: " +
hash.get("values"));
}
Does
your NPE occur on the line where you do result.getValue(), or does it occur when
you reference the return value, e.g. the hash.get() call in the above code?After
reading the code, your next step in debugging is typically to run TcpTunnelGui
provided with Apache SOAP to capture the messages between the endpoints. I
don't recall what the docs look like for TcpTunnelGui, but http://www.scottnichol.com/basicapachesoapcoding.htm gives a
very basic example of using it.Scott Nichol
Do not send e-mail directly
to this e-mail address,
because it is filtered to accept only mail
from
specific mail lists.
----- Original Message -----
From: "Liam
DeMasi" <[EMAIL PROTECTED]>
To:
<[EMAIL PROTECTED]>
Sent: Tuesday, August 05, 2003 1:56
PM
Subject: SOAP getValue() returns NULL
> I am having a
problem with a simple service and client that I have created.
> The server
and client are both on the same Linux machine.
>
> The service keeps
track of the number of method calls it receives from the
> client and
returns that value. Or at least it should. The problem I am
> having is
that when I run the client, I get that the Parameter class
> getValue() is
returning null from the service. The exact error message that
> I receive
is "Exception in thread 'main' java.lang.NullPointerException at
>
mypackage.io.Program_Name"
>
> Can you give me any tips on what this
problem might be? This is my first
> attempt at SOAP.
>
>
thank you.
>
> Liam A. DeMasi
> Atlantic Consulting Services,
Inc.
> 167 Ave at the Commons, Suite 4
> Shrewsbury, NJ
07702
> (732) 460-9416 x15
> (732) 460-9419 (FAX)
>
[EMAIL PROTECTED]
>
>
>
- SOAP getValue() returns NULL Liam DeMasi
- Re: SOAP getValue() returns NULL Scott Nichol
- RE: SOAP getValue() returns NULL Liam DeMasi
- Re: SOAP getValue() returns NULL Scott Nichol
- RE: SOAP getValue() returns NULL Liam DeMasi
- Re: SOAP getValue() returns NULL Scott Nichol
- RE: SOAP getValue() returns NULL Liam DeMasi
- Re: SOAP getValue() returns NULL Liam DeMasi
- Re: SOAP getValue() returns NULL Scott Nichol
