axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Sauthier <Guillaume.Sauth...@objectweb.org>
Subject SOAPElement.getValue() returning null
Date Mon, 06 Dec 2004 09:27:13 GMT
Hi all

I think I found another weird behavior in Axis :)

I've got a JAXRPC client handler, that modify the SOAP Message in the 
request step. In order to do this, it navigate from the SOAPMessage of 
the MessageContext to the SOAPBody; iterates on the body childs 
SOAPElement (representing operation name), and for each operation, it 
iterates too on the operation childs elements (parameters).
Finally, it invoke SOAPElement.getValue() on the parameter for 
retrieving the inner value of the param (wich is a String in my case). 
And this call return always null !

Schematically :
SOAPMessage
->SOAPPart
  ->SOApEnvelope
    ->SOAPBody
      ->* SOAPElement (operation)
        ->* SOAPElement (parameter)
          -> getValue() (=null)

After a little debugging, i found that the final SOAPElement I get is 
for real a RPCParam instance. Going a little deeper, I discover that 
RPCParam "delegate" to MessageElement (its super class) the getValue() 
call that return null. Here is a code snippet (comments inside) :

//======================================================
    /**
     * Get the value of the doc as a string.
     * This uses {@link #getAsDOM()} so is a heavyweight operation.
     * @return the value of any child node, or null if there is no 
node/something went
     * wrong during serialization. If the first child is text, the 
return value
     * is the text itself.
     * @see javax.xml.soap.Node#getValue() ;
     */
    public String getValue() {

        // no recorder for me
        // ======================
        if ((recorder != null) && (!_isDirty)) {
            StringWriter writer = new StringWriter();
            TextSerializationContext outputContext =
                new TextSerializationContext(writer);
            try {
                recorder.replay(startEventIndex,
                                endEventIndex,
                                new SAXOutputter(outputContext));
            } catch (Exception t) {
                log.debug("getValue()", t);
                return null;
            }
            String value = writer.toString();
            return (value.length() == 0) ? null : value;
        }

        // textRep is null for me
        // ======================
        if (textRep != null) {
            // weird case: error?
            return textRep.getNodeValue();
        }

        // objectValue too
        // ======================
        if (objectValue != null) {
            return getValueDOM();
        }

        // children too
        // ======================
        if (children != null && !children.isEmpty()) {
            if (children.get(0) instanceof org.apache.axis.message.Text) {
                return 
((org.apache.axis.message.Text)children.get(0)).getNodeValue();
            }
        }

        // then, it always return null
        // ======================
        return null;
    }
//======================================================

But there is other thing I view when debugging : RPCParam has a field 
named "value" with value accessible via getObjectValue(). And this is 
this value that I want to be returned.

Maybe we can add a RPCParam.getValue() that return this.getObjectValue() ??

Regards
Guillaume

Mime
View raw message