axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Glenn Bech" <glenn.b...@webstep.no>
Subject Problem parsing/retrieving information from SOAPBody in a handler
Date Fri, 16 Dec 2005 00:34:03 GMT
Hi!

I really hope someone can provide some insight on this as It's been driving
me crazy for a while. Short story; I can't seem to be able to retrieve the
elements of a SOAPBody from my "BasicHandler". 

I'm writing ha handler that works on a response message from a "LOGIN"
service. 

The task of the handler is to store an association between the returned
"SessionID" (Given from my "LOGIN" service) with the actual HTTP Session. 

Client will later send the Session ID in the SOAP Header, and its 
value get compared to the one associated with the HTTP Session. 

It's declared like this in my deploy.wssd.

<responseFlow>
            <handler name="StoreSession"
type="java:com.product.service.webservice.StoreSession" />
</responseFlow>

The Outgoiung SOAP Message looks like this ;

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <LoginResponse
xmlns="http://schemas.company.com/cai3g1.0/2004/01/22/">
            <sessionId>11346898949530991623220</sessionId>
            <baseSequenceId>1134689894953</baseSequenceId>
        </LoginResponse>
    </soapenv:Body>
</soapenv:Envelope>

My handler code looks like this. It is invoked, after the Pivot, but the
results are bizarre. When using the method getChildElements() in SOAPElement
to retrieve the content of the soap Body, the sessionId and baseSequenceId
are nowhere to be found (!) 

Instead it seems that the object hiearachy looks like this ;


SOAPBody  (1 child) 
|	- LoginResponse (has 1 child) 
		- LoginResponse (has 0 children)

---8< CODE SNIPPET -- 8 < --


Looking at my handler code ;
final SOAPPart sp = messageContext.getMessage().getSOAPPart();
final SOAPEnvelope spEnvelope = sp.getEnvelope();
final SOAPBody spBody = messageContext.getMessage().getSOAPBody();

Iterator i = spBody.getChildElements();
if (i.hasNext())
{
	log.debug("SOAPBody Element has child elements...");
}
SOAPBodyElement loginResponseElement = (SOAPBodyElement) i.next();
log.debug("First Child of SOAPBody should be LoginResponse. It is " +
	loginResponseElement.getLocalName());

i = loginResponseElement.getChildElements();
SOAPElement element = (SOAPElement) i.next();
log.debug("First Child of loginResponse element should be SessionID, it is
not! It is : " + element.getLocalName());

---8< CODE SNIPPET ENDS -- 8 < --

Output the following debug log 

- SOAPBody Element has child elements...
- First Child of SOAPBody should be LoginResponse. It is LoginResponse
- First Child of loginResponse element should be SessionID, it is not! It is
: LoginRespons

Am I Missing something very obvious here ? Bug ? 

Best regards, any help will be very welcome !!

glenn richard bech





Mime
View raw message