More curious behaviour... I suspected name space problems, after doing some
more googling on problems with getChildElements(). 

Doing some more debug logging... While working on the SOAP Message

<?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.ericsson.com/cai3g1.0/2004/01/22/";>
            <sessionId>11347240199840991623220</sessionId>
            <baseSequenceId>1134724019984</baseSequenceId>
        </LoginResponse>
</soapenv:Body>

With the following code: 

Name loginResName = spEnvelope.createName("LoginResponse", "ns1",
"http://schemas.company.com/cai3g1.0/2004/01/22/";);

Iterator i = spBody.getChildElements(loginResName);
SOAPBodyElement loginResponseElement = (SOAPBodyElement) i.next();
if (log.isDebugEnabled())
{
        log.debug("Got the 'LoginResponse' element of SOAP Body  " +
loginResponseElement);
        log.debug("Got the 'LoginResponse'. It's FirstChild is   " +
loginResponseElement.getFirstChild());
        log.debug("Got the 'LoginResponse'. It's LastChild is   " +
loginResponseElement.getLastChild());
}

I Get the following output: 

* Got the 'LoginResponse' element of SOAP Body  <LoginResponse
xmlns="http://schemas.ericsson.com/cai3g1.0/2004/01/22/";><sessionId>11347247
135460991623220</sessionId><baseSequenceId>1134724713562</baseSequenceId></L
oginResponse>

* Got the 'LoginResponse'. It's FirstChild is  <ns1:LoginResponse
xmlns:ns1="http://schemas.ericsson.com/cai3g1.0/2004/01/22/";><ns1:sessionId>
11347247135460991623220</ns1:sessionId><ns1:baseSequenceId>1134724713562</ns
1:baseSequenceId></ns1:LoginResponse>

* Got the 'LoginResponse'. It's LastChild is   <ns1:LoginResponse
xmlns:ns1="http://schemas.ericsson.com/cai3g1.0/2004/01/22/";><ns1:sessionId>
11347247135460991623220</ns1:sessionId><ns1:baseSequenceId>1134724713562</ns
1:baseSequ

What on earth is going on here? You have no Idea on how happy I will be if
anyone could shed some light on this for me . 

Best regads, and happy weekends to all of you !

Glenn





-----Original Message-----
From: Glenn Bech [mailto:[EMAIL PROTECTED] 
Sent: 16. desember 2005 01:34
To: [email protected]
Subject: Problem parsing/retrieving information from SOAPBody in a handler

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






Reply via email to