A couple of things:

1. Is this really a single line in your deployment descriptor?  There is a 'feature' 
that may give an NPE when there is whitespace as part of this element.

<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>

2. You create your document using

      Document doc = new org.apache.xerces.dom.DocumentImpl();

That this may not be namespace aware could be a problem.  I think nightly builds might 
handle it, but I am not sure and would be suspicious of release builds.  A more 
standard Apache SOAP thing to do would be to use XMLParserUtils.getXMLDocBuilder() as 
the builder for your document, as this sets namespace awareness, etc.

3. If it still NPEs, create your response payload as a string manually to rule out a 
marshaling quirk as the problem.  For example, the POProcessor messaging sample does
 
    StringBuffer response = new StringBuffer(1024);
    response.append(Constants.XML_DECL)
            .append("<SOAP-ENV:Envelope 
xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\";>")
            .append("<SOAP-ENV:Body>")
            .append("<purchaseOrderResponse xmlns=\"urn:po-processor\">")
            .append("<return>")
            .append("OK thanks, got the PO for orderDate ")
            .append(orderDate)
            .append("; we'll contact you when ready.")
            .append("</return>")
            .append("</purchaseOrderResponse>")
            .append("</SOAP-ENV:Body>")
            .append("</SOAP-ENV:Envelope>");
 
    resCtx.setRootPart(response.toString(), "text/xml");

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: "Tony Vieitez" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 24, 2003 4:36 AM
Subject: null pointer exception


> Hi 
>  
> I am a newbie to soap and web services and I am getting an exception
> that I cannot find the cause to. Is there anyone that can help?
> I have tried to build the simplest client and service possible. When the
> client invokes a service, the xml that it gets back is a null pointer
> exception. I just cannot find the cause of the problem. Here is the
> exception:
>  
> <?xml version='1.0' encoding='UTF-8'?>
> <SOAP-ENV:Envelope
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
> <SOAP-ENV:Body>
> <SOAP-ENV:Fault>
> <faultcode>SOAP-ENV:Server.Exception:</faultcode>
> <faultstring>java.lang.NullPointerException</faultstring>
> <faultactor>/soap/servlet/messagerouter</faultactor>
> </SOAP-ENV:Fault>
> </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>  
> Here is the deployment descriptor for the web service
>  
> <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment";
> id="ani" type="message">
>   <isd:provider type="java" scope="Application" methods="responsaQuery">
>     <isd:java class="altituderesponsatest.Processor" static="false"/>
>   </isd:provider>
>  
>  
> <isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultLis
> tener>
> </isd:service>
>  
> Here is the web service:
> package altituderesponsatest;
> //import statements 
>  
> public class Processor {
>  
>   public void responsaQuery(Envelope env, SOAPContext req, SOAPContext
> res)
>         throws IOException, MessagingException {
>       Document doc = new org.apache.xerces.dom.DocumentImpl();
>       Element response = doc.createElement("response");
>       Vector bodyEntries = new Vector();
>       bodyEntries.add(response);
>       StringWriter writer = new StringWriter();
>       env.marshall(writer, null);
>       res.setRootPart(writer.toString(), "text/xml");
>     }
> }
>  
> Any help would be very much appreciated
>  
> Tony
>  
>  
>

Reply via email to