Hi,

Be sure to check the errata and Examples archive for "Programming Web
Services with SOAP" at http://www.oreilly.com/catalog/progwebsoap/ .
There appears to be a number of small errors in the examples, especially
in the URI and the location of class files.

I got rid of the NullPointer exception by upgrading to j2sdk1.4.0 on
Windows NT. On Unix (Slackware Linux) I'm using jdk1.3.1_02 with the VM
engine set to "classic" in order to get it to work.

In addition to this I had to do a lot of CLASSPATH shuffling in
tomcat.bat/tomcat.sh in order to get every class included in the right
order. On Windows NT, the CLASSPATH ended up looking like this:

Using CLASSPATH:
C:\J2sdk1.4.0\lib\tools.jar;C:\SOAP\xerces-1_4_4\xerces.jar;C:\
SOAP\soap-2_2\lib\soap.jar;C:\SOAP\soap-2_2\lib\mail.jar;C:\SOAP\soap-2_2\lib\ac
tivation.jar;C:\SOAP\soap-2_2;c:\soap\jakarta-tomcat-3.2.4\classes;c:\soap\jakar
ta-tomcat-3.2.4\lib\ant.jar;c:\soap\jakarta-tomcat-3.2.4\lib\crimson.jar;c:\soap
\jakarta-tomcat-3.2.4\lib\jasper.jar;c:\soap\jakarta-tomcat-3.2.4\lib\jaxp.jar;c
:\soap\jakarta-tomcat-3.2.4\lib\servlet.jar;c:\soap\jakarta-tomcat-3.2.4\lib\web
server.jar;c:\j2sdk1.4.0\lib\tools.jar

(Don't know why I had to include tools.jar explicitly in the
beginning, but it didn't work without it).


The client uses a CLASSPATH looking like this:

CLASSPATH=c:\soap\xerces-1_4_4;c:\soap\soap-2_2\lib\soap.jar;c:\soap\soap-2_2\li
b\mail.jar;c:\soap\soap-2_2\lib\activation.jar;c:\soap

Then it works:

C:\SOAP>java Hello_client http://localhost:8080/soap/servlet/rpcrouter
Chris


Calling the SOAP Server to say hello


The SOAP Server says: Hello from Windows NT Chris



Best wishes
Steen Linden


On Mon, 25 Feb 2002, Carver, Christopher wrote:

> --Problem:
> When trying to recieve a SOAP message from my server I get the following error:
>
> Exception in thread "main" [SOAPException: faultCode=SOAP-ENV:Protocol; 
>msg=Unsupported response content type "text/html", must be: "text/xml". Response was:
> <h1>Error: 500</h1>
> <h2>Location: /soap/servlet/messagerouter</h2><b>Internal Servlet Error:</b><br>
> <pre>javax.servlet.ServletException: Error building response envelope: 
>java.lang.NullPointerException
>
> This is my first attempt in using SOAP and I am able to run the
> samples cleanly that came with Apache SOAP. I'm trying to execute the
> example from the OReilly Book "Programming Wes Services with SOAP."
>
> --Here is my execution string from the command line:
> java Example1_client http://localhost:8080/soap/servlet/messagerouter Chris
>
> --Here is the client code:
>
> import java.io.*;
> import java.net.*;
> import java.util.*;
> import org.apache.soap.util.xml.*;
> import org.apache.soap.*;
> import org.apache.soap.rpc.*;
>
> public class Example1_client {
>    public static void main (String[] args) throws Exception {
>       System.out.println("\n\nCalling the SOAP server to say hello.\n\n");
>       URL url = new URL(args[0]);
>       String name = args[1];
>
>       Call call = new Call();
>       call.setTargetObjectURI("urn:Example1");
>       call.setMethodName("sayHello");
>       call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
>       Vector params = new Vector();
>       params.addElement(new Parameter("name", String.class, name, null));
>       call.setParams(params);
>
>       System.out.println("The SOAP Server says: ");
>
>       Response resp = call.invoke(url, "");
>
>       if (resp.generatedFault()) {
>          Fault fault = resp.getFault();
>          System.out.println("Fault Code   = " + fault.getFaultCode());
>          System.out.println("Fault String = " + fault.getFaultString());
>       } else {
>          Parameter result = resp.getReturnValue();
>          System.out.println(result.getValue());
>          System.out.println();
>       }
>    }
> }
>
> --Here is the server code:
>
> package samples;
>
> public class Hello {
>    public String sayHello(String name) {
>       return "Hello " + name;
>    }
> }
>



Reply via email to