users@saaj.java.net

Re: [SAAJ-USR] SOAPElement#addChildElement() question?

From: V B Kumar Jayanti <Vbkumar.Jayanti_at_Sun.COM>
Date: Wed, 16 Mar 2005 10:31:14 +0530

Hi,

Jongjin Choi wrote:

>Dear V B Kumar,
>
>Thanks for your response.
>
>The problem is, I think, that the users of SAAJ API expect same behavior under other implementation of SAAJ,
>but they get different result under other SAAJ implementation.
>I think this undocumented behavior may hurts the application portability.
>
>In my testing, I got the different results with Axis1.2 and WebLogic 9 beta.
>IMO, If this behavior is recommended, this should be documented or checked by TCK.
>
>
the next spec revision of SAAJ will include a clarification on this.

>One thing,
>if I modify the code like this:
>
>SOAPElement sq = sb.addChildElement("getStockQuote", "", "http://www.tempuri.org/stockquote"); // (1)
>SOAPElement symbol = sq.addChildElement("symbol", "", "");
>
>expecting that the result will be:
><getStockQuote xmlns="http://www.tempuri.org/stockquote">
><symbol xmlns="">... </symbol>
></getStockQuite>
>
>
this should also be doable with the next release of SAAJ RI

regards,
kumar

>But the result is:
><getStockQuote xmlns="http://www.tempuri.org/stockquote">
><symbol>... </symbol>
></getStockQuite>
>

>
>Thanks.
>
>/Jongjin
>----- Original Message -----
>From: "V B Kumar Jayanti" <Vbkumar.Jayanti_at_Sun.COM>
>To: <users_at_saaj.dev.java.net>
>Sent: Tuesday, March 15, 2005 8:53 PM
>Subject: Re: [SAAJ-USR] SOAPElement#addChildElement() question?
>
>
>
>
>>Jongjin Choi wrote:
>>
>>
>>
>>>Hi,
>>>
>>>I hava a question about SOAPElement#addChildElement().
>>>
>>>With the following code,
>>>
>>>SOAPMessage msg = MessageFactory.newInstance().createMessage();
>>>SOAPEnvelope se = msg.getSOAPPart().getEnvelop();
>>>SOAPBody sb = se.getBody();
>>>SOAPElement sq = sb.addChildElement("getStockQuote", "ns1", "http://www.tempuri.org/stockquote"); // (1)
>>>SOAPElement symbol = sq.addChildElement("symbol");
>>>System.out.println("sq.getNamespaceURI() = " + sq.getNamespaceURI());
>>>System.out.println("symbol.getNamespaceURI() = " + symbol.getNamespaceURI());
>>>msg.writeTo(System.out);
>>>
>>>The result is (I reformat SOAP message for readability) :
>>>sq.getNamespaceURI() = http://www.tempuri.org/stockquote
>>>symbol.getNamespaceURI() = null
>>>
>>><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
>>><SOAP-ENV:Header/>
>>><SOAP-ENV:Body>
>>><ns1:getStockQuote xmlns:ns1="http://www.tempuri.org/stockquote">
>>><symbol>FOO</symbol>
>>></ns1:getStockQuote>
>>></SOAP-ENV:Body>
>>></SOAP-ENV:Envelope>
>>>
>>>So far so good, but I change (1) of the above code
>>>SOAPElement sq = sb.addChildElement("getStockQuote", "", "http://www.tempuri.org/stockquote");
>>>
>>>The result is :
>>>sq.getNamespaceURI() = http://www.tempuri.org/stockquote
>>>symbol.getNamespaceURI() = http://www.tempuri.org/stockquote
>>>
>>><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
>>><SOAP-ENV:Header/>
>>><SOAP-ENV:Body>
>>><getStockQuote xmlns="http://www.tempuri.org/stockquote">
>>><symbol>FOO</symbol>
>>></getStockQuote>
>>></SOAP-ENV:Body>
>>></SOAP-ENV:Envelope>
>>>
>>>It's strange. I think the result should be (under soapbody):
>>><getStockQuote xmlns="http://www.tempuri.org/stockquote">
>>><symbol xmlns="">FOO</symbol>
>>></getStockQuote>
>>>
>>>It seems that SOAPElement.addChildElement() behaves differently whether the parent element has prefix or not.
>>>The SAAJ 1.2 spec is not clear about this. Is this a bug of currrent SAAJ impl or Is it intentional?
>>>
>>>
>>>
>>>
>>I agree that the spec is not clear on this. But this has been the
>>behavior of SAAJ impl.
>>Are you stuck because of this ?.
>>
>>thanks.
>>
>>
>>
>>
>>>I tested it under SUN Java System Application Server PE8 2005Q1, but JWSDP 1.5 gives the same result.
>>>
>>>Thanks.
>>>
>>>/Jongjin Choi
>>>
>>>
>>>
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe_at_saaj.dev.java.net
>>For additional commands, e-mail: users-help_at_saaj.dev.java.net
>>
>>
>>
>>