axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Williamson" <>
Subject RE: addAttribute/setType problem
Date Tue, 29 Oct 2002 17:10:09 GMT
I think there is a bug or two in org.apache.axis.message.MessageElement.  I
have looked through the MessageElement class (which I use extensively).  I
believe there are two problems that I can see.

The first problem is I don't think the namespaces are ever added to the
attributes during the output method.  Therefor namespaces that are added to
the MessageElement using the addNamespaceDeclaration are never saved and
sent to the output.

The second problem is when addAttribute(String, String, QName) is used.  The
QName attributes are turned into Strings while calling the output method.
The output method takes a SerializationContext as a parameter.  This context
is used to turn the the QName into a string using the qName2String method.
When it does this, it generates a prefix for the NamespaceURI and registers
it with the context.  The problem is a new context is created everytime the
getAsString method is called.  Therefor the namespace mappings are lost,
since they are not stored with the MessageElement and rather with the

Anyway there needs to be an easy way to remember these namespace
declarations.  The methods provided are very nice.  I just believe they do
not accomplish all that they mean to accomplish.

Could someone with some knowledge on this class, please let me know if I am
way off on this.  If not, what is the best route to proceed in fixing this.
I could not find this in bugzilla.  Shall I submit a bug?  Thanks, for any

Chris Williamson

> -----Original Message-----
> From: Chris Williamson []
> Sent: Monday, October 28, 2002 4:46 PM
> To:
> Subject: addAttribute/setType problem
> I am building a custom serializer and I am having a problem with
> setting the
> type in a MessageElement while making a client call.
> I need to set the type for an object to a Qname of
> {}string.  However, if I call setType it
> makes the QName use the namespace URI of
> The service I am using expects it to be the first one.  The
> second URI is of
> course one of the SOAP11Constants I use by default.  First I guess I would
> like to know why it normalizes this to the second when I specify it as the
> first.  Is there a way to disable this?
> In addition, I tried to add an attribute using the addAttribute call in
> MessageElement.  I specify the namespaceURI, localName, and value (as a
> QName).  It works at first.  If I print out the SOAPEnvelope it adds the
> namespace declaration properly and sets the type with the appropriate
> prefix.  However, if I print it out again, the prefix remains, but the
> namespace declaration is gone.  Even if I don't print it out again, it is
> gone when I invoke the operation.
> Has anyone used MessageElements extensively and have any advice on adding
> attributes?  I am wondering if this is a bug or if I am doing something
> wrong.  Given that it seems to work at first, makes me think there is a
> small bug.
> These two methods are very useful as they let me use QName and I
> don't need
> to map namespaces.  Is there another option for a workaround?  Or should I
> just add the namespaces manually.  Is there a way to generate a unique
> namespace?
> I have included two SOAPEnvelopes...the first is what I wish to
> get and what
> I get when I print out the message the first time while using
> addAttribute.
> The second message is what I get when I print the SOAPEnvelope the second
> time.
> Thanks,
> Chris Williamson
> What it should look like...
> <soapenv:Envelope
> xmlns:soapenv=""
> \
> xmlns:xsd="" \
> xmlns:xsi="">
>  <soapenv:Body>
>   <ns1:AuthorSearchRequest xmlns:ns1="urn:PI/DevCentral/SoapService">
>    <AuthorSearchRequest xsi:type="ns1:AuthorRequest">
>     <author xsi:type="ns2:string" \
> xmlns:ns2="">Stephen Wolfram</author>
>     <page xsi:type="ns3:string" \
> xmlns:ns3="">1</page>
>     <mode xsi:type="ns4:string" \
> xmlns:ns4="">books</mode>
>     <tag xsi:type="ns5:string" \
> xmlns:ns5="">webservices-20</tag>
>     <type xsi:type="ns6:string" \
> xmlns:ns6="">lite</type>
>     <devtag xsi:type="ns7:string" \
> xmlns:ns7="">D3VZJS46JD5U9D</devtag>
>     <version xsi:type="ns8:string" \
> xmlns:ns8="">1.0</version>
>    </AuthorSearchRequest>
>   </ns1:AuthorSearchRequest>
>  </soapenv:Body>
> </soapenv:Envelope>
> What I get the second time...
> <soapenv:Envelope
> xmlns:soapenv=""
> \
> xmlns:xsd="" \
> xmlns:xsi="">
>  <soapenv:Body>
>   <ns1:AuthorSearchRequest xmlns:ns1="urn:PI/DevCentral/SoapService">
>    <AuthorSearchRequest xsi:type="ns1:AuthorRequest">
>     <author xsi:type="ns2:string">Stephen Wolfram</author>
>     <page xsi:type="ns3:string">1</page>
>     <mode xsi:type="ns4:string">books</mode>
>     <tag xsi:type="ns5:string">webservices-20</tag>
>     <type xsi:type="ns6:string">lite</type>
>     <devtag xsi:type="ns7:string">D3VZJS46JD5U9D</devtag>
>     <version xsi:type="ns8:string">1.0</version>
>    </AuthorSearchRequest>
>   </ns1:AuthorSearchRequest>
>  </soapenv:Body>
> </soapenv:Envelope>

View raw message