You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by marcello <m....@storming.it> on 2007/09/05 12:22:20 UTC

handler: response message manipulation

I'm dealing with a service which sends back a response that's not complying
with the service WSDL. In details, it sometimes sends an attribute set to "
" (blank) while the attribute itself is defined as integer. The result is a
"java.lang.reflect.InvocationTargetException" during deserialization phase.

Waiting for the service provider to fix the issue, I'm trying to write an
handler to remove the message elements containing the offending attribute
(those elements are defined with minOccurs=0) with the following
(simplified) code on Axis 1.1:

public void invoke(MessageContext msgContext) throws AxisFault {

    Message response = msgContext.getResponseMessage();
    SOAPEnvelope responseEnvelope = response.getSOAPEnvelope();
    SOAPBodyElement sbe = (SOAPBodyElement) responseEnvelope.getFirstBody();
    Iterator it =
sbe.getChildElements(responseEnvelope.createName(LOCNAME,"",URI));
    if ( it != null ) {
        while ( it.hasNext() ) {
            sbe.removeChild((MessageElement)it.next());
        }
    }
}

Inspecting the message I can see that it's not containing the offending
elements anymore, so I expected no more errors in the deserialization.
Unfortunately, it is not the case. The deserializer still fails with the
same exception on the same elements (that I can't see anymore at the end of
the handler) as before.

I've also tried with a responseEnvelope.removeBodyElement(sbe) before
modifications and a responseEnvelope.addBodyElement(sbe) before leaving the
method, but it doesn't help.

I'm missing something needed to let the axis engine know that the message
has changed? Or what else?

I've also tried a different approach, dealing with the DOM document obtained
with sbe.getAsDocument() which gave me other problems, object of the next
post.

Any hints?

Thanks in advance.

Marcello Desantis
Storming Sas

-- 
View this message in context: http://www.nabble.com/handler%3A-response-message-manipulation-tf4383140.html#a12494997
Sent from the Axis - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org