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
{http://www.w3.org/1999/XMLSchema}string.  However, if I call setType it
makes the QName use the namespace URI of http://www.w3.org/2001/XMLSchema.
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="http://schemas.xmlsoap.org/soap/envelope/";
\
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; \
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
 <soapenv:Body>
  <ns1:AuthorSearchRequest xmlns:ns1="urn:PI/DevCentral/SoapService">
   <AuthorSearchRequest xsi:type="ns1:AuthorRequest">
    <author xsi:type="ns2:string" \
xmlns:ns2="http://www.w3.org/1999/XMLSchema";>Stephen Wolfram</author>
    <page xsi:type="ns3:string" \
xmlns:ns3="http://www.w3.org/1999/XMLSchema";>1</page>
    <mode xsi:type="ns4:string" \
xmlns:ns4="http://www.w3.org/1999/XMLSchema";>books</mode>
    <tag xsi:type="ns5:string" \
xmlns:ns5="http://www.w3.org/1999/XMLSchema";>webservices-20</tag>
    <type xsi:type="ns6:string" \
xmlns:ns6="http://www.w3.org/1999/XMLSchema";>lite</type>
    <devtag xsi:type="ns7:string" \
xmlns:ns7="http://www.w3.org/1999/XMLSchema";>D3VZJS46JD5U9D</devtag>
    <version xsi:type="ns8:string" \
xmlns:ns8="http://www.w3.org/1999/XMLSchema";>1.0</version>
   </AuthorSearchRequest>
  </ns1:AuthorSearchRequest>
 </soapenv:Body>
</soapenv:Envelope>

What I get the second time...

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";
\
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; \
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
 <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>

Reply via email to