--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