You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by St...@aon.com on 2002/02/05 18:46:10 UTC

Re: A note on Body.unmarshall() [Virus Checked]

I looked at what you are doing. You should think about what .unmarshall() is
for. The idea is that we would want to create a new Body object on the server
given an XML representation of the object. The outer tags of the XML
representation are <SOAP-ENV: body> tags. They are not internal structure tags.
The unmarshall method is therefore not trying to use them to make the internal
state of the Body object.

To see this more clearly, take a Body object and .marshall() it to a
PrintWriter(System.out). You will see the XML "serialization"/representation of
a Body object that the unmarshall() method is expecting to have as input.

HTH,

S-






"Mittermaier, Christian" <Ch...@fabasoft.com> on 02/05/2002
11:54:00 AM

Please respond to soap-user@xml.apache.org

To:   soap-user@xml.apache.org, soap-dev@xml.apache.org
cc:    (bcc: Steve Salkin/3rd/US/AON)

Subject:  A note on Body.unmarshall()  [Virus Checked]


Hi all,

I want to contribute a note on the Body.unmarshall() method of Apache SOAP 2.2
and
additionally maybe someone can help me to get clar about this point, as it seems
somehow
strange to me.

The point is the following:
I am using document style SOAP for my requests and services. When writing a Java
client
I was constructing the XML information as a DOM tree as in the following
example:

Document doc = new DocumentImpl();
Element query = doc.createElement("Query");
query.appendChild(doc.createTextNode("Some Query String"));
doc.appendChild(query);

Then I tried to put this DOM tree into the body of my SOAP-message:

Envelope soapEnv = new Envelope();
Body soapBody = Body.unmarshall(query, new SOAPContext());
soapEnv.setBody(soapBody);

I considered this to be valid (in whatever sense) and intuitively clear, but it
is definitely not. I always received an empty <Body> element at the server side.

Inspecting the source code of the unmarshall() method of the Body class, I
realized that DOMUtils.getFirstChildElement() is applied to the node input
parameter
of unmarshall(). So actually, as in my example there is only the "root" element
with
no further children, nothing was unmarshalled.

When I put an additional element on top of the <Query> element, i.e. make the
XML look like the following:
<Wrap>
  <Query>Some Query String</Query>
</Wrap>

it works out fine.

I don't know if this behavior is intended, at least I did not find any
documentation
about it and it seems to be a pitfall, anyway.

Hope to get some suggestions/clarifications,

Chris
(See attached file: C.DTF)