php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31755 Cannot create SOAP header in no namespace
Submitted: 2005-01-29 22:48 UTC Modified: 2005-02-02 10:14 UTC
From: adam at trachtenberg dot com Assigned: dmitry (profile)
Status: Closed Package: SOAP related
PHP Version: 5CVS-2005-01-29 (dev) OS: n/a
Private report: No CVE-ID: None
 [2005-01-29 22:48 UTC] adam at trachtenberg dot com
Description:
------------
You cannot create a SOAP header that is in no namespace. (This 
is required by the new Google Adwords SOAP API, see https://
adwords.google.com/api/adwords/v2/TrafficEstimatorService?
wsdl.)

Furthermore, the SOAPHeader class allows you to create headers 
in an empty namespace, by passing in null or "" for the 
namespace URI. This is illegal. (Unless defined as the default 
namespace.)

The extension should be changed to place these elements in no 
namespace instead.

Reproduce code:
---------------
$client=new SOAPClient(null, array('location' => 'http://localhost', 'uri' => 'myNS', 'exceptions' => false, 'trace' => true));

$header = new SOAPHeader(null, 'foo', 'bar');

$response= $client->__call('function', array(), null, $header);

print $client->__getLastRequest();


Expected result:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/
soap/envelope/" xmlns:ns1="myNS" xmlns:xsd="http://www.w3.org/
2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/
encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/
soap/encoding/"><SOAP-ENV:Header><foo>bar<foo></SOAP-
ENV:Header><SOAP-ENV:Body><ns1:function/></SOAP-ENV:Body></
SOAP-ENV:Envelope>


Actual result:
--------------
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/
soap/envelope/" xmlns:ns1="myNS" xmlns:ns2="" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/
encoding/"><SOAP-ENV:Header><ns2:foo>bar</ns2:foo></SOAP-
ENV:Header><SOAP-ENV:Body><ns1:function/></SOAP-ENV:Body></
SOAP-ENV:Envelope>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-31 16:17 UTC] dmitry@php.net
SOAP specification doesn't allow non-namespace-qualified headers.

I am not sure, but I think you sould use "https://adwords.google.com/api/adwords/v2" as namespace for these SOAP headers.

 [2005-01-31 18:35 UTC] amt@php.net
Thanks. Using "https://adwords.google.com/api/adwords/v2" does work.

I talked with the people at Google, and I guess some SOAP toolkits are not sophisticated enough to produce SOAP headers inside a specific namespace, which is why the other option is available.

However, I still think it's a bug that you can do this:

new SOAPHeader(null, 'foo', 'bar');

As you end up putting element "foo" in an empty namespace. I believe that is illegal XML. (xmllint issues a warning if this happens.)
 [2005-01-31 20:07 UTC] amt@php.net
Here is the line from the XML NS spec:

http://www.w3.org/TR/REC-xml-names/

Section 2

[Definition:] If the attribute name matches PrefixedAttName, then the NCName gives the namespace prefix, used to associate element and attribute names with the namespace name in the attribute value in the scope of the element to which the declaration is attached. In such declarations, the namespace name may not be empty.
 [2005-02-02 10:14 UTC] dmitry@php.net
Fixed in CVS (HEAD and PHP_5_0).

Now you will get a error with empty namespace:

Fatal error: SoapHeader::__construct(): Invalid parameters. Invalid namespace.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 07:01:29 2024 UTC