开发者

Send a SOAPMessage with SAAJ to a servlet on Tomcat

开发者 https://www.devze.com 2023-03-19 11:41 出处:网络
I have a web application running on Tomcat 6 and a Java-programmed client application. The client send SOAPMessage to a Proxy servlet that validate the message and forwards it to the right web service

I have a web application running on Tomcat 6 and a Java-programmed client application. The client send SOAPMessage to a Proxy servlet that validate the message and forwards it to the right web service. I use SAAJ to send SOAPMessage on client:

    SOAPMessage soap = soapFactory.createMessage();
    SOAPBody body = soap.getSOAPBody();
    body.addDocument( document );

    SOAPConnectionFactory soapFactory = SOAPConnectionFactory.newInstance();
    SO开发者_开发技巧APConnection connection = soapFactory.createConnection();

    SOAPMessage response = connection.call(soap, PROXY_URL);

That work fine, but I need that Proxy servlet implements sessions using cookie (JSESSION).

How can I retrive that cookie from the response? Do you know if exists a better way to do it?


@mattevigo: I believe you are mixing two things. SOAP is a application level protocol which in your case using HTTP transport protocol. You have choices of opening a HTTPConnection and do lower level work and can use HTTP cookie for session management OR you can open SOAPConnection to work with directly SOAP message at higher level.I believe SAAJ api as such does not let you work on HTTP data directly. What you can do is open HTTP connection for communication and use SAAJ API to parse incoming XML and fetch data.

0

精彩评论

暂无评论...
验证码 换一张
取 消