<!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">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;">
    How to set HTTP-Headers correctly
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/ctian">Christian Buss</a> in <i>JBoss Web Services</i> - <a href="http://community.jboss.org/message/534711#534711">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Starting with WS-Clients, i am facing a problem with http-headers.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The following Code puts http-headers into the request&#160; context. It works as expected with metro-libs, but with jbossws-libs&#160; nothing is added:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: courier new,courier;">&#160;&#160;&#160;&#160;&#160;&#160; HelloPerson port = new&#160; HelloPersonService().getHelloPersonPort();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; BindingProvider provider = (BindingProvider) port;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Map&lt;String, List&lt;String&gt;&gt; map = (Map&lt;String,&#160; List&lt;String&gt;&gt;) <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; provider.getRequestContext().get(MessageContext.HTTP_REQUEST_HEADERS);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (map == null)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; map = new HashMap&lt;String, List&lt;String&gt;&gt;();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; map.put("Cookie", Collections.singletonList(<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; "SOMETHING=YES; domain=my.domain.net; path=/"));<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; map.put("Authorization", Collections.singletonList(<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; "Basic " +&#160; Base64.encodeBytes(("basicAuthUser:basicAuthPwd").getBytes())));<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("Adding to HttpRequestHeaders [map="+map+"]&#160; ...");<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; provider.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS,&#160; map);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; String retObj = port.helloTest("Teststring");</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I generated the client stubs with wsconsume (jbossws) and wsimport (metro).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>To run the client i execute wsrunclient.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>under jboss-4.2.2.GA (jbossws-native-2.0.1.SP2):</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: courier new,courier;">set JBOSS_HOME=D:\jboss-4.2.2.GA<br/> set JAVA_HOME=D:\Bibliotheken\jdk1.5.0_05<br/> %JBOSS_HOME%\bin\wsrunclient -classpath&#160; "..\build\classes;%JBOSS_HOME%\lib\jboss-common.jar" test.ws1.PersonServiceClient</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>and under jboss-5.1.0.GA (Native Client: 3.1.2.GA)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: courier new,courier;">set JBOSS_HOME=D:\jboss-5.1.0.GA<br/> set&#160; JAVA_HOME=D:\Bibliotheken\jdk1.5.0_05<br/> %JBOSS_HOME%\bin\wsrunclient&#160; -classpath&#160; "..\build\classes;%JBOSS_HOME%" test.ws1.PersonServiceClient</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>with metro-libs i use the following script:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: courier new,courier;">set METRO_HOME=D:\Bibliotheken\metro-1.5<br/></span></p><p><span style="font-family: courier new,courier;">set METRO_CLASSPATH=%METRO_CLASSPATH%;%METRO_HOME%\lib\webservices-api.jar<br/></span></p><p><span style="font-family: courier new,courier;">set METRO_CLASSPATH=%METRO_CLASSPATH%;%METRO_HOME%\lib\webservices-extra-api.jar<br/></span></p><p><span style="font-family: courier new,courier;">set METRO_CLASSPATH=%METRO_CLASSPATH%;%METRO_HOME%\lib\webservices-rt.jar <br/></span></p><p><span style="font-family: courier new,courier;">set METRO_CLASSPATH=%METRO_CLASSPATH%;%METRO_HOME%\lib\webservices-extra.jar <br/></span></p><p><span style="font-family: courier new,courier;">set METRO_CLASSPATH=%METRO_CLASSPATH%;%METRO_HOME%\lib\webservices-tools.jar<br/></span></p><p><span style="font-family: courier new,courier;"><br/></span></p><p><span style="font-family: courier new,courier;">set JAVA_HOME=D:\Bibliotheken\jdk1.5.0_05 </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"><span style="font-family: courier new,courier;"> </span>&#160;</p><p><span style="font-family: courier new,courier;"> %JAVA_HOME%\bin\java -classpath "..\build\classes;%METRO_CLASSPATH%" test.ws1.PersonServiceClient</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I deployed the web service as a stateless session&#160; bean.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I would be very thankful for any help!! Regards,</p><p>Christian</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/534711#534711">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>