You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Frank Zhou <fc...@yahoo.com> on 2008/01/23 20:54:26 UTC

Urgent Help! AXIS 1.4 SoapEnvelope error

Hi All, 

I've been struggling with the following error that has
to do with deserializing a soapEnvelope, can anyone
help? Thanks much.

Frank
=====================================================
I am using AXIS 1.4 for my web service needs. I try to
send an XML message over HTTP, the XML message defines
a namespace at the root element like this:
  
    xmlns:ns1="somthing"
  
Let me assume this xml string as xmltext, now I create
a soap envelope with this XML message as body, the
soapEnvelope object seems good to me in my debugger, 
but a problem occurs when I try to deserialize it 
using soapEnvelope.toString() or
soapEnvelope.getAsString().I notice that for every 
local element in the original xml such as this:
  
     <ns1:rec>xxx</ns1:rec>,
  
in the output string, I get the the following:
  
     <ns1:rec xmlns:ns1="">xxx</ns1:rec>
  
That is, there is an extra attribute with empty value.
This causes problems for the receivers of the http
response.

Here is the soapEnvelope dump:

<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:RecordSet
xmlns:ns1="http://xxxx.com/yyy_out"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
         <ns1:Record xmlns:ns1="">
            <ns1:PROSPECT_NUMBER
xmlns:ns1="">10</ns1:PROSPECT_NUMBER>
            <ns1:FIRM xmlns:ns1="">Business
Objects</ns1:FIRM>
            <ns1:FIRST_NAME
xmlns:ns1="">Ryan</ns1:FIRST_NAME>
            <ns1:MIDDLE_NAME xmlns:ns1=""/>
            <ns1:LAST_NAME
xmlns:ns1="">Champlin</ns1:LAST_NAME>
</ns1:Record>
         </ns1:RecordSet>
      </soapenv:Body>
   </soapenv:Envelope>
  
Here are my code snappet: 

 ===================================================
  SOAPEnvelope soapEnvelope = new SOAPEnvelope();
  Element bodyElement =
createDocument(xmltext).getDocumentElement();
  org.apache.axis.message.SOAPBodyElement
messageElement = new
org.apache.axis.message.SOAPBodyElement(bodyElement);

soapEnvelope.addBodyElement((SOAPBodyElement)messageElement);
 
  The createDocument(xmlText) calls the following
APIs:

  InputSource source = new InputSource( new
StringReader( xmlText ) ) ;
  DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();

  factory.setIgnoringElementContentWhitespace(false);
  DocumentBuilder docBuilder =
factory.newDocumentBuilder();
  return docBuilder.parse(source);



      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org