axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alastair FETTES" <afet...@mdacorporation.com>
Subject RE: Namespace problem between header and body
Date Tue, 19 Sep 2006 17:06:07 GMT
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


Mime
View raw message