[ 
http://issues.apache.org/jira/browse/AXIS-2312?page=comments#action_12358650 ] 

Jayachandra Sekhara Rao Sunkara commented on AXIS-2312:
-------------------------------------------------------

Hi Roman!
To explain about the "ns1" namespace..., axis tags element names with the 
namespace of the nearest parent/grandparent up the hierarchy in the special 
case of no specific namespace being mentioned in the xml.
(There is some specification guideline that made it adopt this behaviour, if my 
understanding is right)
Hence you see the "http://htng.org/1.1/Header/"; namespace for "From" element.

Now for the java code part of it, may be u may want to get the header namespace 
first and create the Name object appropriately and use that Name object to 
getChildElements

sth like...

                SOAPHeader header = pmsPostReqEnvelope.getHeader(); 
                // [BEGIN CODE]
                String nsURI = header.getElementName().getURI();
                Name fromName = 
envelope.createName("From","headerprefix",nsURI); 
                // [END CODE]

HTH,
Jayachandra

> SAAJ SOAPElement has phantom prefix in it's children.
> -----------------------------------------------------
>
>          Key: AXIS-2312
>          URL: http://issues.apache.org/jira/browse/AXIS-2312
>      Project: Apache Axis
>         Type: Bug
>   Components: SAAJ
>     Versions: 1.3
>  Environment: Manbdrake 10.0 Tomcat 5.5.9
>     Reporter: Roman Levandovsky

>
> Here is the XML
> <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:Header>
>   <HTNGHeader schemaLocation="http://htng.org/1.1/Header/ 
> http://webservices.micros.com/htng/HTNGHeader.xsd"; 
> soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"; 
> soapenv:mustUnderstand="0" xmlns="http://htng.org/1.1/Header/";>
>    <From>
>     <systemid>SOAPClient</systemid>
>     <address>http://localhost</address>
>     <Credential>
>      <username>user</username>
>      <password>pass</password>
>     </Credential>
>    </From>
>    <To>
>     <systemid>PMSMonitorService</systemid>
>     <address>http://localhost:8080/axis/services/PMSMonitor</address>
>    </To>
>    <timeStamp>2005-10-25T09:06:50.000</timeStamp>
>    <echoToken>randomstring</echoToken>
>    <action>getPMSStatus</action>
>   </HTNGHeader>
>  </soapenv:Header>
>  <soapenv:Body>
>   <GetHello xmlns="">
>    <hello xmlns="">Hello Earthling</hello>
>   </GetHello>
>  </soapenv:Body>
> </soapenv:Envelope>
> The Java code tries to extract the child element from the rootHeaderElement 
> which in this example is HTNGHeader. The child element has the name From.
> What happens is this, after calling 
> rootHeaderElem.getChildElements(fromName); the iter variable contains 
> nothing. When I look in the debugger, children of rootHeaderElem all have ns1 
> as the prefix even though no prefixes were present in the original xml. When 
> I look at the xml of rootHeaderElem non of it has any prefixes and looks like 
> this 
> <HTNGHeader schemaLocation="http://htng.org/1.1/Header/ 
> http://webservices.micros.com/htng/HTNGHeader.xsd"; 
> soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"; 
> soapenv:mustUnderstand="0" xmlns="http://htng.org/1.1/Header/"; 
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";><From><systemid>SOAPClient</systemid><address>http://localhost</address><Credential><username>user</username><password>pass</password></Credential></From><To><systemid>PMSMonitorService</systemid><address>http://localhost:8080/axis/services/PMSMonitor</address></To><timeStamp>2005-10-25T09:06:50.000</timeStamp><echoToken>randomstring</echoToken><action>getPMSStatus</action></HTNGHeader>
> The child XML looks like this
> <ns1:From 
> xmlns:ns1="http://htng.org/1.1/Header/";><ns1:systemid>SOAPClient</ns1:systemid><ns1:address>http://localhost</ns1:address><ns1:Credential><ns1:username>user</ns1:username><ns1:password>pass</ns1:password></ns1:Credential></ns1:From>
> Naturally the getChildElements(fromName); method can't find any children 
> because the From child has a ns1 prefix associated with it.
>                 SOAPHeader header = pmsPostReqEnvelope.getHeader();
>                 Name fromName = envelope.createName("From");
>                 // get the header element
>                 Iterator iter = header.getChildElements();
>                 SOAPElement rootHeaderElem = (SOAPElement) iter.next();
>                 
>                 // get the From element
>                 iter = rootHeaderElem.getChildElements(fromName);

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to