[jboss-user] [JBoss Web Services] - Is there a way to access the information send in the SOAPHeader within an endpoint EJB?

Maria Sanchez do-not-reply at jboss.com
Wed Jul 14 12:44:12 EDT 2010


Maria Sanchez [http://community.jboss.org/people/mesanchez] created the discussion

"Is there a way to access the information send in the SOAPHeader within an endpoint EJB?"

To view the discussion, visit: http://community.jboss.org/message/552588#552588

--------------------------------------------------------------
I have installed JBoss6.0.0M3 which deploys woth JBossws3.3.0.
I am trying to see if it is possible to access the information passed as part of the SOAP header within the endpoint EJB. I have been able to use handlers to manipulate the SOAP Message, but I am not able to find information regarding access from the EJB. 
There are some pages that indicate that this is possible using the SessionContext. The handlers set some attributes that are later accessed from the EJB, this would work but  I do not find any code that I could use as a reference. Any ideas? Code examples?

This is the code I found but it has problems:

public class MyMessageHandler extends 
               javax.xml.rpc.handler.GenericHandler { 
   public boolean handleRequest(MessageContext mc) {
          SOAPMessage msg = ((SOAPMessageContext)mc).getMessage() ;
          SOAPPart sp = msg.getSOAPPart();
          SOAPEnvelope se = sp.getEnvelope();
          SOAPHeader header = se.getHeader();
          SOAPBody body = se.getBody();             
          if (header == null) {
               // raise error
          }
          for (Iterator iter = header.getChildElements(); 
                              iter.hasNext();) {
               SOAPElement element = (SOAPElement) iter.next();
               if (element.getElementName().getLocalName()
                         .equals("PriorityProcessing")) {
                    mc.setProperty("PriorityProcessing", 
                         element.getValue());
               }
          }
     ...
     return true;
}

#
| *Code Example 8.6* Passing Context Information from Handler to Endpoint

 |

Then, you can get access to MessageContext in the endpoint that receives the request. For an EJB service endpoint, MessageContext is available with the bean'sSessionContext.  http://java.sun.com/blueprints/guidelines/designing_webservices/html/architecture6.html#1154641 Code Example 8.7 shows the enterprise bean code for the endpoint.
public class EndpointBean implements SessionBean {
     private SessionContext sc;     
     public void businessMethod() {
          MessageContext msgc= sc.getMessageContext();
          String s = (String)msgc.getProperty("PriorityProcessing");
          Boolean priority = new Boolean(s);
          ...
     }       
     public void setSessionContext(SessionContext sc) {
          this.sc = sc;
     }
     ...
}

#
| *Code Example 8.7* Endpoint Receiving Context Information from a Handler

 |

When I do this SessionContext object is null

Thanks,
   Maria

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/552588#552588]

Start a new discussion in JBoss Web Services at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2044]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100714/8dd15142/attachment.html 


More information about the jboss-user mailing list