I believe this is working completely as specified. The MessageContext.HTTP_RESPONSE_HEADER return the headers that came in for the very last response only. They aren't supposed to be an aggregate. Since responses 2 and 3 don't have the JSESSIONID in the headers, they wouldn't be in the map of headers.

Dan



On Jun 16, 2008, at 2:03 PM, Landslide wrote:


I took the latest code drop of CXF 2.1 and built a test client as below to retrieve HTTP session header info sent back from my CXF SOAP server (2.1):

public class WsClientNoWsse {

        /**
         * @param args
         */
        @SuppressWarnings("unchecked")
        public static void main(String[] args) {
                
                SoapService_Service service = new SoapService_Service();
                SoapService port = service.getSoapServicePort();
                
                BindingProvider bp = (BindingProvider)port;
bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,
true);

                try {
                        String result = port.sayHi("John");
                        System.out.println("SOAP response: " + result);
                        
                        Map<String, List<String>> headers = (Map<String,
List<String>>) ((BindingProvider )port).getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
                        System.out.println("Headers: " + headers);
                        List<String> header = headers.get("Set-Cookie");
                        if (header != null && !header.isEmpty()) {
                                for (int i=0; i<header.size(); i++) {
                                        System.out.println("Header: " + 
header.get(i));
                                }
                        }

                        result = port.sayHi("Peter");
                        System.out.println("SOAP response: " + result);
                        
                        headers = null;
                        header = null;
                        headers = (Map<String,
List<String>>) ((BindingProvider )port).getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
                        System.out.println("Headers: " + headers);
                        header = headers.get("Set-Cookie");
                        if (header != null && !header.isEmpty()) {
                                for (int i=0; i<header.size(); i++) {
                                        System.out.println("Header: " + 
header.get(i));
                                }
                        }
                        
                        result = port.sayHi("Mary");
                        System.out.println("SOAP response: " + result);
                        
                        headers = null;
                        header = null;
                        headers = (Map<String,
List<String>>) ((BindingProvider )port).getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
                        System.out.println("Headers: " + headers);
                        header = headers.get("Set-Cookie");
                        if (header != null && !header.isEmpty()) {
                                for (int i=0; i<header.size(); i++) {
                                        System.out.println("Header: " + 
header.get(i));
                                }
                        }

                } catch(Exception e) {
                        e.printStackTrace();
                }

        }

}

The following was my test result. As could be seen, the CXF 2.1 client did
retrieve HTTP session header info correctly in the 1st response, which
contained 2 different cookies (MyCookie and JSESSIONID). However, in the 2nd
and 3rd responses, the CXF 2.1 client failed to retrieve the cookie
"JSESSIONID" correctly since its value has not been modified by my SOAP
server since its 1st response.

SOAP response 1: Hello, John
Headers: {Content-Length=[237], X-Powered-By=[Servlet 2.4; JBoss-4.0.5.GA
(build: CVSTag=Branch_4_0 date=200610162339)/Tomcat-5.5],
Set-Cookie=[MyCookie=1FBE5EDFF76385CC9F194BD4DD4C727B127.0.0.1; Version=1, JSESSIONID=1FBE5EDFF76385CC9F194BD4DD4C727B; Path=/], Date=[Mon, 16 Jun 2008
17:44:21 GMT], SOAPAction=[""], Server=[Apache-Coyote/1.1],
content-type=[text/xml;charset=UTF-8]}
Header: MyCookie=1FBE5EDFF76385CC9F194BD4DD4C727B127.0.0.1; Version=1
Header: JSESSIONID=1FBE5EDFF76385CC9F194BD4DD4C727B; Path=/

SOAP response 2: Hello, Peter
Headers: {Content-Length=[238], X-Powered-By=[Servlet 2.4; JBoss-4.0.5.GA
(build: CVSTag=Branch_4_0 date=200610162339)/Tomcat-5.5],
Set- Cookie=[MyCookie=1FBE5EDFF76385CC9F194BD4DD4C727B127.0.0.1Modified1;
Version=1], Date=[Mon, 16 Jun 2008 17:44:21 GMT], SOAPAction=[""],
Server=[Apache-Coyote/1.1], content-type=[text/xml;charset=UTF-8]}
Header: MyCookie=1FBE5EDFF76385CC9F194BD4DD4C727B127.0.0.1Modified1;
Version=1

SOAP response 3: Hello, Mary
Headers: {Content-Length=[237], X-Powered-By=[Servlet 2.4; JBoss-4.0.5.GA
(build: CVSTag=Branch_4_0 date=200610162339)/Tomcat-5.5],
Set- Cookie=[MyCookie=1FBE5EDFF76385CC9F194BD4DD4C727B127.0.0.1Modified2;
Version=1], Date=[Mon, 16 Jun 2008 17:44:21 GMT], SOAPAction=[""],
Server=[Apache-Coyote/1.1], content-type=[text/xml;charset=UTF-8]}
Header: MyCookie=1FBE5EDFF76385CC9F194BD4DD4C727B127.0.0.1Modified2;
Version=1

On my SOAP server side, I did receive the returned cookies (both of them) correctly for all 3 requests as the following 2 lines of code were working
correctly on the CXF client side:

        BindingProvider bp = (BindingProvider)port;
        bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,
true);

--
View this message in context: 
http://www.nabble.com/CXF-2.1-client-does-not-retrieve-HTTP-session-header-info-correctly-tp17870106p17870106.html
Sent from the cxf-user mailing list archive at Nabble.com.


---
Daniel Kulp
[EMAIL PROTECTED]
http://www.dankulp.com/blog




Reply via email to