<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Is there a way to access the information send in the SOAPHeader within an endpoint EJB?
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/mesanchez">Maria Sanchez</a> in <i>JBoss Web Services</i> - <a href="http://community.jboss.org/message/552588#552588">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I have installed JBoss6.0.0M3 which deploys woth JBossws3.3.0.</p><p>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. </p><p>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&#160; I do not find any code that I could use as a reference. Any ideas? Code examples?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This is the code I found but it has problems:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre>public class MyMessageHandler extends 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;javax.xml.rpc.handler.GenericHandler { 
&#160;&#160; public boolean handleRequest(MessageContext mc) {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SOAPMessage msg = ((SOAPMessageContext)mc).getMessage() ;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SOAPPart sp = msg.getSOAPPart();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SOAPEnvelope se = sp.getEnvelope();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SOAPHeader header = se.getHeader();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SOAPBody body = se.getBody();&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (header == null) {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;// raise error
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for (Iterator iter = header.getChildElements(); 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;iter.hasNext();) {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SOAPElement element = (SOAPElement) iter.next();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (element.getElementName().getLocalName()
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.equals("PriorityProcessing")) {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;mc.setProperty("PriorityProcessing", 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;element.getValue());
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;&#160;...
&#160;&#160;&#160;&#160;&#160;return true;
}
</pre><p><a class="jive-link-anchor-small" name="1154618">#</a></p><table cellspacing="0"><tbody><tr valign="baseline"><td><span style="font-size: 10pt;"><strong>Code Example 8.6 </strong>Passing Context Information from Handler to Endpoint<br/><br/></span></td></tr></tbody></table><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Then, you can get access to <code>MessageContext</code> in the endpoint that receives the request. For an EJB service endpoint, <code>MessageContext</code> is available with the bean's<code>SessionContext</code>. <a class="jive-link-external-small" href="http://java.sun.com/blueprints/guidelines/designing_webservices/html/architecture6.html#1154641">Code Example 8.7</a> shows the enterprise bean code for the endpoint.</p><pre>public class EndpointBean implements SessionBean {
&#160;&#160;&#160;&#160;&#160;private SessionContext sc;&#160;&#160;&#160;&#160;&#160;
&#160;&#160;&#160;&#160;&#160;public void businessMethod() {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;MessageContext msgc= sc.getMessageContext();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;String s = (String)msgc.getProperty("PriorityProcessing");
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Boolean priority = new Boolean(s);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;...
&#160;&#160;&#160;&#160;&#160;}&#160;&#160;&#160;&#160;&#160;&#160; 
&#160;&#160;&#160;&#160;&#160;public void setSessionContext(SessionContext sc) {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;this.sc = sc;
&#160;&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;&#160;...
}
</pre><p><a class="jive-link-anchor-small" name="1154641">#</a></p><table cellspacing="0"><tbody><tr valign="baseline"><td><span style="font-size: 10pt;"><strong>Code Example 8.7 </strong>Endpoint Receiving Context Information from a Handler<br/><br/><code></code></span></td></tr></tbody></table><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>When I do this SessionContext object is null</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks,</p><p>&#160;&#160; Maria</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/552588#552588">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Web Services at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2044">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>