3 Replies Latest reply on Oct 10, 2007 8:17 PM by Shane Bryzak

    NullPointerException in org.jboss.seam.webservice.SOAPReques

    Oliver Treichel Newbie

      I tried to write a conversational webservice with seam 2.0.0.CR2

      My first problem was that the documented way of putting a standard-jaxws-endpoint-config.xml file into META-INF didn't work at all. Instead I added a handler-chain to sun-jaxws.xml.

      <?xml version="1.0" encoding="UTF-8"?>
      <endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">
       <endpoint name="Hello" implementation="hello.Hello" url-pattern="/ws/hello">
       <handler-chains xmlns="http://java.sun.com/xml/ns/javaee">
       <handler-name>SOAP Request Handler</handler-name>

      This way the SOAPRequestHandler was callled, but it threw a NullPointerException:
       at org.jboss.seam.webservice.SOAPRequestHandler.handleOutbound(SOAPRequestHandler.java:107)
       at org.jboss.seam.webservice.SOAPRequestHandler.handleMessage(SOAPRequestHandler.java:56)

      The Exception was caused by the following statement in org.jboss.seam.webservice.SOAPRequestHandler line 107 where getSOAPHeader() returns null:
      SOAPMessageContext smc = (SOAPMessageContext) messageContext;
      SOAPElement element = smc.getMessage().getSOAPHeader().addChildElement(CIDQN);

      If I change the code to:
      SOAPMessageContext smc = (SOAPMessageContext) messageContext;
      SOAPMessage msg = smc.getMessage();
      SOAPPart part = msg.getSOAPPart();
      SOAPEnvelope env = part.getEnvelope();
      SOAPHeader header = env.getHeader();
      if (header == null) {
       header = env.addHeader();
       SOAPElement element = header.addChildElement(CIDQN);

      then the webservice works as expected.

      So my question is: Is this a bug in seam, or is something wrong with my setup?

      btw.: I'm running seam 2.0.0.CR2 with jax-ws 2.1.1 and jdk1.5.0_13 on tomcat 6.0.14