axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roshan Weerasuriya <ros...@opensource.lk>
Subject Re: setUri() API - Usage
Date Tue, 11 Jan 2005 09:47:59 GMT
hi All,
                                                                                         
                                                                                  
Currently in the code we use the Attribute class as the place holder for
Attributes and Namespces(i.e Namespace declarations). The Attribute
class has the following private memebers.
                                                                                         
                                                                                  
private:
    bool isSerializable() const;
    AxisString m_localname;
    AxisString m_prefix;
    AxisString m_uri;
    AxisString m_value;
                                                                                         
                                                                                  
Case 1
------
In case of a attribute for eg:".... env:mustUnderstand="true" the
following is the case currently:
                                                                                         
                                                                                  
m_localname will be "mustUnderstand"
m_prefix will be "env"
m_uri will be "the namespace uri associated with this prefix"
m_value will be "true"
                                                                                         
                                                                                  
Case 2
--------
In case of a Namespace declaration eg: "...
xmlns:t="http://example.org/2001/06/tx" the following is the case
currently.
                                                                                         
                                                                                  
m_localname will be "t"
m_prefix will be "xmlns"
m_uri will be "THE PROBLME IS THAT HERE THE URI WILL BE EMPTY IN THE
CURRENT STRUTURE"
m_value will be "http://example.org/2001/06/tx"
                                                                                         
                                                                                  
                                                                                         
                                                                                  
Now come the problem: We have the following mehtods in the Attribute
class.
                                                                                         
                                                                                  
void setValue(const AxisChar* value);
    void setUri(const AxisChar* uri);
    void setPrefix(const AxisChar* prefix);
    void setLocalName(const AxisChar* localname);
                                                                                         
                                                                                  
So in the above case1 if a user want to set/change the URI he will call
the "setUri" method and that will work.
But in above case2 if a user want to set/change the URI he will be
naturaly calling the "setUri" method but as I have explained in the
above case2, it is the value variable which actualy holds the namespace
uri, so that calling setUri will not change the URI eventhoug the user
think so. So in this design if the user wants to change the namespce uri
in case2, he actualy have to call the "setValue()" method. This is
because the serialization mechanism is build in to the Attribute class
and to make the serialized out put as expected the above is the
mechanism applied.
                                                                                         
                                                                                  
So what I propose is to introduce a new class as a palce holder for
namespaces (i.e actualy for namespace declarations). eg:
class Namespace
{
public:
        void setURI(AxisString asURI);
        void setPrefix(AxisString asPrefix);
        Namespace(AxisString asPrefix, AxisString asURI);
        Namespace();
        virtual ~Namespace();
                                                                                         
                                                                                  
private:
        AxisString m_asPrefix;
        AxisString m_asURI;
                                                                                         
                                                                                  
};
                                                                                         
                                                                                  
And it will have its corrosponding INamespce interface as well.
                                                                                         
                                                                                  
so the code would look like:
IHeaderBlock
*phb=ws.createSOAPHeaderBlock("TestHeader","http://axis.com");
INamespace *namesp=phb->createNamespaceDecl("np","http://apache.com");
namesp->setUri("new_uri");
                                                                                         
                                                                                  
Please provide any of your ideas.
                                                                                         
                                                                                  
Roshan


On Mon, 2005-01-10 at 19:04, Roshan Weerasuriya wrote:
> hi James and All,
> 
> createNamespaceDecl() creates and adds. OK yes.. true
> 
> >what is the advantage of having an API addNamespaceDecl() 
> This method was added so that if a user has already created a Namespcae
> direcetly without using the above "createNamespaceDecl()", so that he
> could use this method to add it. But when I went through the code I also
> feel that we could remove this "addNamespaceDecl()" from the API. 
> 
> Any one has a issue if we remove this method ""addNamespaceDecl()" from
> the API? Thanks for James to pointing out this.
> 
> Roshan
> 
> 
> 
> On Mon, 2005-01-10 at 18:09, James Jose wrote:
> > Hi Roshan,
> > 
> > There is no API which  creates the namespace declaration without
> > adding to the HeaderBlock. If createNamespaceDecl() creates and add
> > the namespace to the HeaderBlock , what is the advantage of having an
> > API addNamespaceDecl() ? I am just trying to understand the necessity
> > of addNamespaceDecl() API and how it can be used.
> > 
> > Regards
> > James
> > --------------------------------------------------
> > James Jose
> > Messaging Clients Team, WMQDDC
> > IBM Software Labs, India
> > Direct: 91-80- 25094331  Ext :2331
> > E-mail: jamejose@in.ibm.com
> > 
> > 
> > 
> > 
> > Roshan Weerasuriya
> > <roshan@opensource.lk>
> > 
> > 10/01/2005 16:20
> >          Please respond to
> >   "Apache AXIS C Developers List"
> >                To
> > Apache AXIS C
> > Developers List
> > <axis-c-dev@ws.apache.org>
> >                cc
> > 
> >           Subject
> > Re: setUri() API
> > - Usage
> > 
> > 
> > 
> > 
> > hi James,
> > 
> > >    Also I have some doubt about functionality of addNamespaceDecl()
> > - 
> > 
> > if you use the ".. *attr=phb->createNamespaceDecl()" method it will
> > create and also add the namespace declaration to the HeaderBlock. So
> > you
> > don't need to explictly call the "phb->addNamespaceDecl(attr)" and if
> > you do so it will duplicate the namespcae declartion. (We use a list
> > internaly so it just add the second one also). That causes this
> > problem
> > of server receiving a invalied content.
> > 
> > It is mentioned in the createNamespaceDecl() API comments that it
> > creates and adds.
> > 
> > Roshan
> > 
> > On Mon, 2005-01-10 at 10:03, Roshan Weerasuriya wrote:
> > > hi James,
> > > 
> > > >    Any idea about setUri() API in IAttribute class.
> > > There seems to be a problem here. I will correct it. Thanks for
> > pointing
> > > it out.
> > > 
> > > Roshan
> > > 
> > > On Fri, 2005-01-07 at 12:48, James Jose wrote: 
> > > > Roshan,
> > > > 
> > > >     Any idea about setUri() API in IAttribute class.
> > > >    
> > > >    Also I have some doubt about functionality of
> > addNamespaceDecl() - 
> > > > 
> > > >  I tried the following code.
> > > > IHeaderBlock
> > > > *phb=ws.createSOAPHeaderBlock("TestHeader","http://axis.com");
> > > >                 IAttribute
> > > > *attr=phb->createNamespaceDecl("np","http://apache.com");
> > > >                 phb->addNamespaceDecl(attr);
> > > > 
> > > > This generates the following SOAP header and results in an
> > Exception.
> > > > <SOAP-ENV:Header><ns2:TestHeader xmlns:ns2="http://axis.com"
> > > > xmlns:np="http://apache.com"
> > > > xmlns:np="http://apache.com"></ns2:TestHeader></SOAP-ENV:Header>
> > > > <SOAP-ENV:Body>
> > > > 
> > > > API documentation for addNamespaceDecl() says it sets the
> > namespace
> > > > declaration of the Header Block.
> > > > 
> > > > 
> > > > 
> > > > 
> > > > Thanks in advance..
> > > > 
> > > > James
> > > > --
> > > > James Jose
> > > > Messaging Clients Team, WMQDDC
> > > > IBM Software Labs, India
> > > > Direct: 91-80- 25094331  Ext :2331
> > > > E-mail: jamejose@in.ibm.com
> > > > 
> > > > 
> > > > 
> > > > 
> > > > James Jose/India/IBM@IBMIN
> > > > 
> > > > 04/01/2005 18:35
> > > >          Please respond to
> > > >   "Apache AXIS C Developers List"
> > > >                To
> > > > axis-c-dev@ws.apache.org
> > > >                cc
> > > > 
> > > >           Subject
> > > > setUri() API -
> > > > Usage
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > > Hi
> > > > 
> > > >   I have used setUri() API in the IAttribute class. But it is not
> > > > changes the SOAP message anyway.
> > > >   ie its not updated the namespace URI associated with the
> > attribute
> > > > prefix in SOAP Message.
> > > > 
> > > >   So I just want to know why this API is used.
> > > > 
> > > >   Thanks in advance
> > > >     James
> > > > 
> > > > --
> > > > James Jose
> > > > Messaging Clients Team, WMQDDC
> > > > IBM Software Labs, India
> > > > Direct: 91-80- 25094331  Ext :2331
> > > > E-mail: jamejose@in.ibm.com
> > > > 
> > > 
> > > 
> > 
> > 
> 
> 


Mime
View raw message