Christian Buss [
http://community.jboss.org/people/ctian] created the discussion
"How to set HTTP-Headers correctly"
To view the discussion, visit:
http://community.jboss.org/message/534711#534711
--------------------------------------------------------------
Starting with WS-Clients, i am facing a problem with http-headers.
The following Code puts http-headers into the request context. It works as expected with
metro-libs, but with jbossws-libs nothing is added:
HelloPerson port = new HelloPersonService().getHelloPersonPort();
BindingProvider provider = (BindingProvider) port;
Map<String, List<String>> map = (Map<String,
List<String>>)
provider.getRequestContext().get(MessageContext.HTTP_REQUEST_HEADERS);
if (map == null)
map = new HashMap<String, List<String>>();
map.put("Cookie", Collections.singletonList(
"SOMETHING=YES;
domain=my.domain.net; path=/"));
map.put("Authorization", Collections.singletonList(
"Basic " +
Base64.encodeBytes(("basicAuthUser:basicAuthPwd").getBytes())));
System.out.println("Adding to HttpRequestHeaders [map="+map+"]
...");
provider.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, map);
String retObj = port.helloTest("Teststring");
I generated the client stubs with wsconsume (jbossws) and wsimport (metro).
To run the client i execute wsrunclient.
under jboss-4.2.2.GA (jbossws-native-2.0.1.SP2):
set JBOSS_HOME=D:\jboss-4.2.2.GA
set JAVA_HOME=D:\Bibliotheken\jdk1.5.0_05
%JBOSS_HOME%\bin\wsrunclient -classpath
"..\build\classes;%JBOSS_HOME%\lib\jboss-common.jar"
test.ws1.PersonServiceClient
and under jboss-5.1.0.GA (Native Client: 3.1.2.GA)
set JBOSS_HOME=D:\jboss-5.1.0.GA
set JAVA_HOME=D:\Bibliotheken\jdk1.5.0_05
%JBOSS_HOME%\bin\wsrunclient -classpath "..\build\classes;%JBOSS_HOME%"
test.ws1.PersonServiceClient
with metro-libs i use the following script:
set METRO_HOME=D:\Bibliotheken\metro-1.5
set METRO_CLASSPATH=%METRO_CLASSPATH%;%METRO_HOME%\lib\webservices-api.jar
set METRO_CLASSPATH=%METRO_CLASSPATH%;%METRO_HOME%\lib\webservices-extra-api.jar
set METRO_CLASSPATH=%METRO_CLASSPATH%;%METRO_HOME%\lib\webservices-rt.jar
set METRO_CLASSPATH=%METRO_CLASSPATH%;%METRO_HOME%\lib\webservices-extra.jar
set METRO_CLASSPATH=%METRO_CLASSPATH%;%METRO_HOME%\lib\webservices-tools.jar
set JAVA_HOME=D:\Bibliotheken\jdk1.5.0_05
%JAVA_HOME%\bin\java -classpath "..\build\classes;%METRO_CLASSPATH%"
test.ws1.PersonServiceClient
I deployed the web service as a stateless session bean.
I would be very thankful for any help!! Regards,
Christian
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/534711#534711]
Start a new discussion in JBoss Web Services at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]