You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by Dan Ciarniello <dc...@cityxpress.com> on 2006/09/19 18:45:18 UTC

Namespace problem between header and body

I am trying to use the wsdl2ws tool to write a C++ client for a web 
service that I have implemented using Java Axis.  I am using Axis-C++ 
v1.6 and Java Axis v1.2.

When making a call using the wsdl2ws generated code, the SOAP envelope 
sent is, for example,

|<?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:Body>
    <ns1:getUser xmlns:ns1="http://cityxpress.com/external">
      <ns1:siteinfo>
        <ns1:partner>cityxpress</ns1:partner>
        <ns1:deployment>master</ns1:deployment>
        <ns1:site>new_demo</ns1:site>
      </ns1:siteinfo>
      <ns1:id>123456</ns1:id>
    </ns1:getUser>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
|
This is fine but I need to add a header to the envelope so I subclassed 
the stub and added the following to the constructor:
|  IHeaderBlock *phb = this->createSOAPHeaderBlock("authinfo", 
"http://cityxpress.com/external", "ai");

  BasicNode *el_node = phb->createChild(ELEMENT_NODE, "user", NULL, 
"http://cityxpress.com/external", NULL);
  BasicNode *t_node = phb->createChild(CHARACTER_NODE);
  t_node->setValue(user);
  el_node->addChild(t_node);
  phb->addChild(el_node);

  el_node = phb->createChild(ELEMENT_NODE, "password", NULL, 
"http://cityxpress.com/external", NULL);
  t_node = phb->createChild(CHARACTER_NODE);
  t_node->setValue(pass);
  el_node->addChild(t_node);
  phb->addChild(el_node);
|
Now, when I make the call to the service, the SOAP envelope is

|<?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>
    <ai:authinfo xmlns:ai="http://cityxpress.com/external">
      <ai:user>username</ai:user>
      <ai:password>password</ai:password>
    </ai:authinfo></SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <ns1:getUser xmlns:ns1="http://cityxpress.com/external">
      <ns1:siteinfo>
        <partner>cityxpress</partner>
        <deployment>master</deployment>
        <site>new_demo</site>
      </ns1:siteinfo>
      <ns1:id>123456</ns1:id>
    </ns1:getUser>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
|
Note that the partner, deployment and site subelements of siteinfo have 
lost their namespace prefix.  This means that the web service ignores 
the values given because the elements are not in the expected namespace.

For the sake of comparison, here is the envelope created by a Java 
version of the client created with WSDL2Java which is understood by the 
web service:

|<?xml version="1.0" encoding="UTF-8"?>
<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>
    <ns1:authinfo 
soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
      soapenv:mustUnderstand="0" xmlns:ns1="http://cityxpress.com/external">
      <ns1:user>username</ns1:user>
      <ns1:password>password</ns1:password>
    </ns1:authinfo>
  </soapenv:Header>
  <soapenv:Body>
    <getUser xmlns="http://cityxpress.com/external">
      <siteinfo>
        <partner>cityxpress</partner>
        <deployment>master</deployment>
        <site>new_demo</site>
      </siteinfo>
      <id>123456</id>
    </getUser>
  </soapenv:Body>
</soapenv:Envelope>

|The obvious question is how do I get the C++ client to generate a SOAP 
Envelope that is comparable to the one created by the Java client?

As an aside, I wanted to try a C client to see if the same problem 
existed but, though wsdl2ws will generate C-code, there don't seem to be 
any C libraries that I can link to.  Are C libraries missing or is there 
a way that I can link C code to the C++ libraries?

Thanks,
Dan.


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


RE: Namespace problem between header and body

Posted by Alastair FETTES <af...@mdacorporation.com>.
Hrm, that wasn't what was causing my problems.  I wasn't even using the
header section when I got this.  I simply found a work around that
worked for me and stuck with it.  Good luck and hopefully this gets
looked in to.

Alastair 

-----Original Message-----
From: Dan Ciarniello [mailto:dciarniello@cityxpress.com] 
Sent: Tuesday, September 19, 2006 2:37 PM
To: Apache AXIS C User List
Subject: Re: Namespace problem between header and body

Alastair FETTES wrote:

>Just a note:
>
>I have encountered this problem as well, quite often I'm afraid.  This
>occurred when I was subclassing and specifically seemed to occur when I
>ref'd elements from a foreign namespace.  To work around this I simply
>included all items in one namespace.  Not an ideal approach but it was
a
>work around none the less.
>  
>
But all elements are in the same namespace.  If I modify the header so 
that it's in a different namespace then I get:

|<?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>
    <ai:authinfo xmlns:ai="http://cityxpress.com">
      <ai:user>dciarniello</ai:user>
      <ai:password>admin</ai:password>
    </ai:authinfo>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <ns1:getUser xmlns:ns1="http://cityxpress.com/external">
      <ns1:siteinfo>
        <ns1:partner>cityxpress</ns1:partner>
        <ns1:deployment>master</ns1:deployment>
        <ns1:site>new_demo</ns1:site>
      </ns1:siteinfo>
      <ns1:id>123456</ns1:id>
    </ns1:getUser>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
|
The namespace prefix is now back on the siteinfo subelements.  For some 
reason, the value of the namespace in the authinfo element in the header

affects the way that the siteinfo element is serialized in the body.

Dan.


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




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


Re: Namespace problem between header and body

Posted by Dan Ciarniello <dc...@cityxpress.com>.
Alastair FETTES wrote:

>Just a note:
>
>I have encountered this problem as well, quite often I'm afraid.  This
>occurred when I was subclassing and specifically seemed to occur when I
>ref'd elements from a foreign namespace.  To work around this I simply
>included all items in one namespace.  Not an ideal approach but it was a
>work around none the less.
>  
>
But all elements are in the same namespace.  If I modify the header so 
that it's in a different namespace then I get:

|<?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>
    <ai:authinfo xmlns:ai="http://cityxpress.com">
      <ai:user>dciarniello</ai:user>
      <ai:password>admin</ai:password>
    </ai:authinfo>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <ns1:getUser xmlns:ns1="http://cityxpress.com/external">
      <ns1:siteinfo>
        <ns1:partner>cityxpress</ns1:partner>
        <ns1:deployment>master</ns1:deployment>
        <ns1:site>new_demo</ns1:site>
      </ns1:siteinfo>
      <ns1:id>123456</ns1:id>
    </ns1:getUser>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
|
The namespace prefix is now back on the siteinfo subelements.  For some 
reason, the value of the namespace in the authinfo element in the header 
affects the way that the siteinfo element is serialized in the body.

Dan.


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


RE: Namespace problem between header and body

Posted by Alastair FETTES <af...@mdacorporation.com>.
Just a note:

I have encountered this problem as well, quite often I'm afraid.  This
occurred when I was subclassing and specifically seemed to occur when I
ref'd elements from a foreign namespace.  To work around this I simply
included all items in one namespace.  Not an ideal approach but it was a
work around none the less.

I've also noticed an interesting generation quirk on the server side
(Axis Java Server) when ref'ing elements from another namespace:

<fooParent xmlns="foo">
    <ns1:barChild xmlns:ns1="bar"/>
    <ns2:barChild xmlns:ns2="bar"/>
    <ns3:barChild xmlns:ns3="bar"/>
    <ns4:barChild xmlns:ns4="bar"/>
    <ns5:barChild xmlns:ns5="bar"/>
</fooParent>

Was this intentional?

Cheers,
Alastair

-----Original Message-----
From: Dan Ciarniello [mailto:dciarniello@cityxpress.com] 
Sent: Tuesday, September 19, 2006 9:45 AM
To: axis-c-user@ws.apache.org
Subject: Namespace problem between header and body

I am trying to use the wsdl2ws tool to write a C++ client for a web 
service that I have implemented using Java Axis.  I am using Axis-C++ 
v1.6 and Java Axis v1.2.

When making a call using the wsdl2ws generated code, the SOAP envelope 
sent is, for example,

|<?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:Body>
    <ns1:getUser xmlns:ns1="http://cityxpress.com/external">
      <ns1:siteinfo>
        <ns1:partner>cityxpress</ns1:partner>
        <ns1:deployment>master</ns1:deployment>
        <ns1:site>new_demo</ns1:site>
      </ns1:siteinfo>
      <ns1:id>123456</ns1:id>
    </ns1:getUser>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
|
This is fine but I need to add a header to the envelope so I subclassed 
the stub and added the following to the constructor:
|  IHeaderBlock *phb = this->createSOAPHeaderBlock("authinfo", 
"http://cityxpress.com/external", "ai");

  BasicNode *el_node = phb->createChild(ELEMENT_NODE, "user", NULL, 
"http://cityxpress.com/external", NULL);
  BasicNode *t_node = phb->createChild(CHARACTER_NODE);
  t_node->setValue(user);
  el_node->addChild(t_node);
  phb->addChild(el_node);

  el_node = phb->createChild(ELEMENT_NODE, "password", NULL, 
"http://cityxpress.com/external", NULL);
  t_node = phb->createChild(CHARACTER_NODE);
  t_node->setValue(pass);
  el_node->addChild(t_node);
  phb->addChild(el_node);
|
Now, when I make the call to the service, the SOAP envelope is

|<?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>
    <ai:authinfo xmlns:ai="http://cityxpress.com/external">
      <ai:user>username</ai:user>
      <ai:password>password</ai:password>
    </ai:authinfo></SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <ns1:getUser xmlns:ns1="http://cityxpress.com/external">
      <ns1:siteinfo>
        <partner>cityxpress</partner>
        <deployment>master</deployment>
        <site>new_demo</site>
      </ns1:siteinfo>
      <ns1:id>123456</ns1:id>
    </ns1:getUser>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
|
Note that the partner, deployment and site subelements of siteinfo have 
lost their namespace prefix.  This means that the web service ignores 
the values given because the elements are not in the expected namespace.

For the sake of comparison, here is the envelope created by a Java 
version of the client created with WSDL2Java which is understood by the 
web service:

|<?xml version="1.0" encoding="UTF-8"?>
<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>
    <ns1:authinfo 
soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
      soapenv:mustUnderstand="0"
xmlns:ns1="http://cityxpress.com/external">
      <ns1:user>username</ns1:user>
      <ns1:password>password</ns1:password>
    </ns1:authinfo>
  </soapenv:Header>
  <soapenv:Body>
    <getUser xmlns="http://cityxpress.com/external">
      <siteinfo>
        <partner>cityxpress</partner>
        <deployment>master</deployment>
        <site>new_demo</site>
      </siteinfo>
      <id>123456</id>
    </getUser>
  </soapenv:Body>
</soapenv:Envelope>

|The obvious question is how do I get the C++ client to generate a SOAP 
Envelope that is comparable to the one created by the Java client?

As an aside, I wanted to try a C client to see if the same problem 
existed but, though wsdl2ws will generate C-code, there don't seem to be

any C libraries that I can link to.  Are C libraries missing or is there

a way that I can link C code to the C++ libraries?

Thanks,
Dan.


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




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