5 Replies Latest reply on Feb 17, 2009 9:00 AM by baz

    Webservices and ConversationId

    baz

      Hello, (Seam 2.1.1GA)


      we have a simple Webservice deployed. We can access the Service successful from a client.
      But the responses from the service miss the conversationID:-(


      So i have debugged my code and found that in org.jboss.seam.webservice.SOAPRequestHandler the header is always null:-(


        public boolean handleOutbound(MessageContext messageContext)
         {
            try
            {                
               HttpServletRequest request = (HttpServletRequest) messageContext.get(MessageContext.SERVLET_REQUEST);
               
               String conversationId = Manager.instance().getCurrentConversationId();
               if (conversationId != null)
               {
                  SOAPMessageContext smc = (SOAPMessageContext) messageContext;
                  
                  SOAPHeader header = smc.getMessage().getSOAPHeader();
                  if (header != null)
                  {
                     SOAPElement element = header.addChildElement(CIDQN);
                     element.addTextNode(conversationId);
                     smc.getMessage().saveChanges();               
                  }            
               }
      


      I do not have a clue what is going on here. How can i add a header to a response?
      Ciao,


      Carsten

        • 1. Re: Webservices and ConversationId
          baz

          Now i have compiled and deployed the seam example seambay (Seam 2.1.1.GA on JBoss AS 4.2.3))
          But this yields only an exception when a service on the webservice testpage is invoked


          14:46:05,732 ERROR [[AuctionService]] Servlet.service() for servlet AuctionService threw exception
          java.lang.UnsupportedOperationException: setProperty must be overridden by all subclasses of SOAPMessage
                  at javax.xml.soap.SOAPMessage.setProperty(SOAPMessage.java:441)
                  at org.jboss.ws.core.soap.SOAPMessageImpl.<init>(SOAPMessageImpl.java:83)
                  at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:171)
                  at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.toSOAPMessage(SOAPFaultHelperJAXWS.java:245)
                  at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.exceptionToFaultMessage(SOAPFaultHelperJAXWS.java:174)
                  at org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS.createFaultMessageFromException(SOAP11BindingJAXWS.java:104)
                  at org.jboss.ws.core.CommonSOAPBinding.bindFaultMessage(CommonSOAPBinding.java:671)
                  at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:488)
                  at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:284)
                  at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:201)
                  at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:134)
                  at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)


          • 2. Re: Webservices and ConversationId
            ulath

            cause of the problem is jdk incompatibility, (jboss-saaj.jar), i think this will help you http://thesmallpotato.blogspot.com/2007/06/jdk-16-jboss-420-ejb3-web-service-axis2.html

            • 3. Re: Webservices and ConversationId
              baz

              Yes that solved the problem with the example. Thanks



              But not my original problem with the empty header and no conversationId set. I am using the Client generated by wsimport.

              • 4. Re: Webservices and ConversationId
                baz

                Hello again,


                the seambay  example does work for us. So it is completly unclear to us why our service does not work.


                Shane, why have you coded your message this way? If there is no header nothing is done:-(


                SOAPHeader header = smc.getMessage().getSOAPHeader();
                            if (header != null)
                            {
                



                Perhaps i can understand what is going on in ourapp, when i knowe the intention behind the above test.
                Thanks
                Carsten

                • 5. Re: Webservices and ConversationId
                  baz

                  Our Webservice is a POJO webservice with a com.sun.xml.ws.transport.http.servlet.WSServlet (configured in web.xml) in front.
                  When a response should be send there is no soapheader, hence no conversationid is set.
                  We have implemented the following workaround.


                  public class OurSOAPRequestHandler extends SOAPRequestHandler {
                      @Override
                      public boolean handleOutbound(MessageContext messageContext) {
                          try {
                              SOAPMessageContext smc = (SOAPMessageContext) messageContext;
                              SOAPHeader header = smc.getMessage().getSOAPHeader();
                              // only add, if header not present
                              if (header == null) {
                                 smc.getMessage().getSOAPPart().getEnvelope().addHeader();
                              }
                              return super.handleOutbound(messageContext);
                          } catch (SOAPException e) {
                              return false;
                          }}}
                  


                  This class is configured in sun-jaxws.xml instead of the original. And voila there is the conversationid
                  Ciao,