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 di...@apache.org on 2005/02/07 17:40:40 UTC

cvs commit: ws-axis/c/tests/auto_build/testcases/output IHeaderBlockTest4Request.out

dicka       2005/02/07 08:40:40

  Modified:    c/src/soap ComplexElement.cpp ComplexElement.h
               c/tests/auto_build/testcases/client/cpp
                        IHeaderBlockTest4Client.cpp
               c/tests/auto_build/testcases/output
                        IHeaderBlockTest4Request.out
  Log:
  When a namespace prefix and uri is specified on a BasicNode, and it's children specify the same uri but not a prefix, they should use the same prefix, without re-declaring the namespace.
  Also updated IHeaderBlockTest4 to verify the correct serialization of child and grandchild nodes.
  
  PR: AXISCPP-357
  Submitted by: Adrian Dick
  Reviewed by: James Jose
  
  Revision  Changes    Path
  1.34      +40 -3     ws-axis/c/src/soap/ComplexElement.cpp
  
  Index: ComplexElement.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/ComplexElement.cpp,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- ComplexElement.cpp	4 Feb 2005 16:57:23 -0000	1.33
  +++ ComplexElement.cpp	7 Feb 2005 16:40:39 -0000	1.34
  @@ -48,7 +48,7 @@
   
   AXIS_CPP_NAMESPACE_START
   
  -ComplexElement::ComplexElement()
  +ComplexElement::ComplexElement():m_pParent(NULL)
   {
       m_pachPrefix = '\0';
       m_pachLocalName = '\0';
  @@ -59,7 +59,7 @@
   }
   
   ComplexElement::ComplexElement(AxisChar *pachLocalName, AxisChar *pachPrefix,
  -                               AxisChar *pachUri)
  +                               AxisChar *pachUri): m_pParent(NULL)
   {
       m_pachLocalName = new AxisChar[strlen(pachLocalName)+1];
       strcpy(m_pachLocalName, pachLocalName);
  @@ -73,7 +73,7 @@
   }
   
   ComplexElement::ComplexElement(const ComplexElement& rCopy)
  -:BasicNode(rCopy), m_pachPrefix(NULL), m_pachLocalName(NULL), m_pachURI(NULL)
  +:BasicNode(rCopy), m_pachPrefix(NULL), m_pachLocalName(NULL), m_pachURI(NULL), m_pParent(NULL)
   {
       this->iNoOfChildren = rCopy.iNoOfChildren;
       
  @@ -115,6 +115,7 @@
       delete [] m_pachPrefix;
       delete [] m_pachLocalName;
       delete [] m_pachURI;
  +    m_pParent = NULL;
   
       /* 
        *Clear the Attributes 
  @@ -186,6 +187,11 @@
   {
       if (pBasicNode)
       {
  +        if (pBasicNode->getNodeType() == ELEMENT_NODE)
  +        {
  +            ComplexElement *pComplexElement = static_cast<ComplexElement*>(pBasicNode);
  +            pComplexElement->setParent(this);
  +        }
           m_children.push_back(pBasicNode);
           iNoOfChildren++;
           return AXIS_SUCCESS;
  @@ -246,6 +252,28 @@
           {    
               bool blnIsNewNamespace = false;
   
  +            // Check if we have no namespace prefix, but do have a namespace URI
  +            if ( (m_pachPrefix == NULL || strlen(m_pachPrefix) == 0)
  +                && (m_pachURI != NULL && strlen(m_pachURI) != 0))
  +            {
  +                // Is this a child node?
  +                if (m_pParent != NULL)
  +                {
  +                    // Does the parent uses the same namespace URI?
  +                    if ( m_pParent->getURI() != NULL 
  +                        && strlen(m_pParent->getURI()) != 0
  +                        && strcmp(m_pachURI, m_pParent->getURI()) == 0)
  +                    {
  +                        // Does the parent have a namespace prefix?
  +                        if (m_pParent->getPrefix() != NULL && strlen(m_pParent->getPrefix()) != 0)
  +                        {
  +                            setPrefix(m_pParent->getPrefix());
  +                            setURI("");
  +                        }
  +                    }
  +                }
  +            }
  +            
               pSZ.serialize("<", NULL);    
               if( (m_pachPrefix != NULL) && (strlen(m_pachPrefix) != 0))
               {                
  @@ -367,6 +395,11 @@
       return AXIS_SUCCESS;
   }
   
  +void ComplexElement::setParent(ComplexElement *parent)
  +{
  +    m_pParent = parent;
  +}
  +
   int ComplexElement::serializeChildren(SoapSerializer& pSZ)
   {
       list<BasicNode*>::iterator itCurrBasicNode= m_children.begin();
  @@ -475,6 +508,10 @@
   }
   
   const AxisChar* ComplexElement::getURI() {
  +    if ((m_pachURI == NULL || strlen(m_pachURI) == 0) && m_pParent != NULL)
  +    {
  +        return m_pParent->getURI();
  +    }
       return m_pachURI;
   }
   
  
  
  
  1.24      +7 -0      ws-axis/c/src/soap/ComplexElement.h
  
  Index: ComplexElement.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/ComplexElement.h,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- ComplexElement.h	17 Dec 2004 11:49:45 -0000	1.23
  +++ ComplexElement.h	7 Feb 2005 16:40:39 -0000	1.24
  @@ -275,6 +275,11 @@
         */
       const AxisChar* getPrefix();
   
  +    /**
  +     * Set a pointer to the parent node.
  +     */
  +    void setParent(ComplexElement *parent);
  +
   private:
       int iNoOfChildren;
       int serializeChildren(SoapSerializer& pSZ);
  @@ -297,6 +302,8 @@
         */
       std::list <Attribute *>::iterator m_viCurrentAttribute;
   
  +    ComplexElement * m_pParent;
  +
   };
   
   AXIS_CPP_NAMESPACE_END
  
  
  
  1.2       +3 -1      ws-axis/c/tests/auto_build/testcases/client/cpp/IHeaderBlockTest4Client.cpp
  
  Index: IHeaderBlockTest4Client.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/tests/auto_build/testcases/client/cpp/IHeaderBlockTest4Client.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IHeaderBlockTest4Client.cpp	2 Feb 2005 16:26:52 -0000	1.1
  +++ IHeaderBlockTest4Client.cpp	7 Feb 2005 16:40:39 -0000	1.2
  @@ -40,9 +40,11 @@
   			cout << "Project Type=" << a->getValue();
   		BasicNode * Bnode7=phb->createChild(CHARACTER_NODE);
   		Bnode7->setValue("AXISCPP");
  +        BasicNode * Bnode4a=phb->createChild(ELEMENT_NODE,"LastPartChild","","http://ws.apache.org/", NULL);
  +        Bnode4->addChild(Bnode4a);
   		Bnode6->addChild(Bnode7);
   		Bnode3->addChild(Bnode2);
  -		Bnode4->addChild(Bnode5);
  +		Bnode4a->addChild(Bnode5);
   		Bnode1->addChild(Bnode3);
   		Bnode1->addChild(Bnode4);
   		phb->addChild(Bnode1);
  
  
  
  1.3       +2 -2      ws-axis/c/tests/auto_build/testcases/output/IHeaderBlockTest4Request.out
  
  Index: IHeaderBlockTest4Request.out
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/tests/auto_build/testcases/output/IHeaderBlockTest4Request.out,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IHeaderBlockTest4Request.out	4 Feb 2005 16:57:23 -0000	1.2
  +++ IHeaderBlockTest4Request.out	7 Feb 2005 16:40:39 -0000	1.3
  @@ -2,11 +2,11 @@
   Host: localhost:13260
   Content-Type: text/xml; charset=UTF-8
   SOAPAction: "Calculator#add"
  -Content-Length: 725
  +Content-Length: 760
   
   <?xml version='1.0' encoding='utf-8' ?>
   <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  -<SOAP-ENV:Header><ns2:TestHeader xmlns:ns2="http://ws.apache.org/"><np:Name xmlns:np="http://ws.apache.org/"><np1:FirstPart xmlns:np1="http://ws.apache.org/">APACHE</np1:FirstPart><np1:LastPart>APACHE</np1:LastPart></np:Name><Project Type="Open Source">AXISCPP</Project>This is a test message</ns2:TestHeader></SOAP-ENV:Header>
  +<SOAP-ENV:Header><ns2:TestHeader xmlns:ns2="http://ws.apache.org/"><np:Name xmlns:np="http://ws.apache.org/"><np1:FirstPart xmlns:np1="http://ws.apache.org/">APACHE</np1:FirstPart><np:LastPart><np:LastPartChild>APACHE</np:LastPartChild></np:LastPart></np:Name><Project Type="Open Source">AXISCPP</Project>This is a test message</ns2:TestHeader></SOAP-ENV:Header>
   <SOAP-ENV:Body>
   <ns1:add xmlns:ns1="http://localhost/axis/Calculator">
   <ns1:arg_0_0>2</ns1:arg_0_0>