axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Manuel Darveau" <manueldarv...@gmail.com>
Subject SOAP session - How to get the SessionContext?
Date Mon, 10 Nov 2008 16:05:32 GMT
Hi,

I am trying to setup a web service using transport or soap scope session.
When using transport scope session everything is working fine. My service
get called the first time with a null session, I create one and save it.
Then, the next time the service is called I get the old session and print
the call #:

    public void ping() {
        MessageContext msgctx = MessageContext.getCurrentMessageContext();
        SessionContext session = msgctx.getSessionContext();
        System.out.println("Got session " + session);
        if (session == null) {
            session = new SessionContext();
            msgctx.setSessionContext(session);
        }

        Integer callNo = (Integer) session.getProperty("callNo");
        if (callNo == null) {
            callNo = 0;
        }

        System.out.println("This is call # " + callNo);
        session.setProperty("callNo", callNo + 1);
    }

However, when I use soap scope, the session is always null. I enabled
addressing on both client and server.
The TCPMon log show valid serviceGroupIDExchange.

*Request/Response 1:*
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
    <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
        <wsa:To>http://127.0.0.1:8888/axis2/services/Ping
        </wsa:To>
        <wsa:MessageID>urn:uuid:*716237A36834687F361226332515246*
        </wsa:MessageID>
        <wsa:Action>urn:ping</wsa:Action>
    </soapenv:Header>
    <soapenv:Body>
        <ns1:ping xmlns:ns1="http://ws.8d.com">
            <firstValue>1</firstValue>
            <secondValue>2</secondValue>
        </ns1:ping>
    </soapenv:Body>
</soapenv:Envelope>

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
    <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
        <wsa:ReplyTo>
            <wsa:Address>http://www.w3.org/2005/08/addressing/none
            </wsa:Address>
            <wsa:ReferenceParameters>
                <axis2:ServiceGroupId xmlns:axis2="
http://ws.apache.org/namespaces/axis2">
                    urn:uuid:*57F4003E4C4BE0DD9A1226332515510*
</axis2:ServiceGroupId>
            </wsa:ReferenceParameters>
        </wsa:ReplyTo>
        <wsa:MessageID>urn:uuid:*57F4003E4C4BE0DD9A1226332515511*
        </wsa:MessageID>
        <wsa:Action>urn:pingResponse</wsa:Action>
        <wsa:RelatesTo>urn:uuid:*716237A36834687F361226332515246*
        </wsa:RelatesTo>
    </soapenv:Header>
    <soapenv:Body>
        <ns:pingResponse xmlns:ns="http://ws.8d.com">
            <return>Gen 0 got '1' and '2'</return>
        </ns:pingResponse>
    </soapenv:Body>
</soapenv:Envelope>

*Request/Response 2:*

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
    <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
        <axis2:ServiceGroupId xmlns:axis2="
http://ws.apache.org/namespaces/axis2"
            wsa:IsReferenceParameter="true">urn:uuid:*
57F4003E4C4BE0DD9A1226332515510*
        </axis2:ServiceGroupId>
        <wsa:To>http://127.0.0.1:8888/axis2/services/Ping
        </wsa:To>
        <wsa:MessageID>urn:uuid:*716237A36834687F361226332517606*
        </wsa:MessageID>
        <wsa:Action>urn:ping</wsa:Action>
    </soapenv:Header>
    <soapenv:Body>
        <ns1:ping xmlns:ns1="http://ws.8d.com">
            <firstValue>3</firstValue>
            <secondValue>4</secondValue>
        </ns1:ping>
    </soapenv:Body>
</soapenv:Envelope>

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
    <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
        <wsa:ReplyTo>
            <wsa:Address>http://www.w3.org/2005/08/addressing/none
</wsa:Address>
            <wsa:ReferenceParameters>
                <axis2:ServiceGroupId xmlns:axis2="
http://ws.apache.org/namespaces/axis2">

urn:uuid:57F4003E4C4BE0DD9A1226332515510</axis2:ServiceGroupId>
            </wsa:ReferenceParameters>
        </wsa:ReplyTo>
        <wsa:MessageID>urn:uuid:*57F4003E4C4BE0DD9A1226332517710*
        </wsa:MessageID>
        <wsa:Action>urn:pingResponse</wsa:Action>
        <wsa:RelatesTo>urn:uuid:*716237A36834687F361226332517606*
</wsa:RelatesTo>
    </soapenv:Header>
    <soapenv:Body>
        <ns:pingResponse xmlns:ns="http://ws.8d.com">
            <return>Gen 0 got '3' and '4'</return>
        </ns:pingResponse>
    </soapenv:Body>
</soapenv:Envelope>

What am I doing wrong? BTW, I formatted the XML so it is easilly readable
but it was all sent on a single line.

Thank you very much!

Manuel

P.S.: This is how I used the ServiceStub generated by wsdl2java (adb):
        PingStub service = new PingStub();

service._getServiceClient().engageModule(Constants.MODULE_ADDRESSING);
        service._getServiceClient().setTargetEPR(new EndpointReference("
http://127.0.0.1:8888/axis2/services/Ping"));
        service._getServiceClient().getOptions().setManageSession(true);

Mime
View raw message