Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ext/soap: Add support for clark notation for namespaces in class map
Closes GH-12411.
- Loading branch information
1 parent
fa218ea
commit e58af7c
Showing
12 changed files
with
466 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--TEST-- | ||
SOAP Classmap 5: SoapClient support for classmap with namespace | ||
--EXTENSIONS-- | ||
soap | ||
--INI-- | ||
soap.wsdl_cache_enabled=0 | ||
--FILE-- | ||
<?php | ||
class TestSoapClient extends SoapClient{ | ||
function __doRequest($request, $location, $action, $version, $one_way = 0): ?string { | ||
return <<<EOF | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.nothing.com" 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:Body> | ||
<ns1:dotest2Response><res xsi:type="ns1:book"> | ||
<a xsi:type="xsd:string">Blaat</a> | ||
<b xsi:type="xsd:string">aap</b> | ||
</res> | ||
</ns1:dotest2Response></SOAP-ENV:Body></SOAP-ENV:Envelope> | ||
EOF; | ||
} | ||
} | ||
|
||
class bookNs { | ||
public $a="a"; | ||
public $b="c"; | ||
} | ||
|
||
class book { | ||
public $a="a"; | ||
public $b="c"; | ||
} | ||
|
||
$options=Array( | ||
'actor' =>'http://schema.nothing.com', | ||
'classmap' => array('book'=>'book', '{http://schemas.nothing.com}book'=>'bookNs') | ||
); | ||
|
||
$client = new TestSoapClient(__DIR__."/classmap.wsdl",$options); | ||
$ret = $client->dotest2("???"); | ||
var_dump($ret); | ||
echo "ok\n"; | ||
?> | ||
--EXPECT-- | ||
object(bookNs)#2 (2) { | ||
["a"]=> | ||
string(5) "Blaat" | ||
["b"]=> | ||
string(3) "aap" | ||
} | ||
ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--TEST-- | ||
SOAP Classmap 6: encoding of inherited objects with namespace | ||
--EXTENSIONS-- | ||
soap | ||
--INI-- | ||
soap.wsdl_cache_enabled=0 | ||
--FILE-- | ||
<?php | ||
class A { | ||
public $x; | ||
function __construct($a){ | ||
$this->x = $a; | ||
} | ||
} | ||
class Attest { | ||
public $x; | ||
function __construct($a){ | ||
$this->x = $a; | ||
} | ||
} | ||
class B extends A { | ||
public $y; | ||
function __construct($a){ | ||
parent::__construct($a); | ||
$this->y = $a + 1; | ||
} | ||
} | ||
|
||
function f($input){ | ||
return new B(5); | ||
} | ||
|
||
class LocalSoapClient extends SoapClient { | ||
private $server; | ||
|
||
function __construct($wsdl, $options) { | ||
parent::__construct($wsdl, $options); | ||
$this->server = new SoapServer($wsdl, $options); | ||
$this->server->addFunction("f"); | ||
} | ||
|
||
function __doRequest($request, $location, $action, $version, $one_way = 0): ?string { | ||
ob_start(); | ||
$this->server->handle($request); | ||
$response = ob_get_contents(); | ||
ob_end_clean(); | ||
return $response; | ||
} | ||
} | ||
|
||
$client = new LocalSoapClient(__DIR__."/classmap006.wsdl", | ||
array('classmap'=>array('A'=>'A','{urn:abt}At'=>'Attest','B'=>'B'))); | ||
print_r($client->f(new Attest('test'))); | ||
?> | ||
--EXPECT-- | ||
B Object | ||
( | ||
[x] => 5 | ||
[y] => 6 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
|
||
<!-- WSDL file generated by Zend Studio. --> | ||
|
||
<definitions name="ab" targetNamespace="urn:ab" xmlns:typens="urn:ab" xmlns:typenst="urn:abt" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"> | ||
<types> | ||
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:ab"> | ||
<xsd:complexType name="A"> | ||
<xsd:sequence> | ||
<xsd:element name="x" type="xsd:anyType"/> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="B"> | ||
<xsd:complexContent> | ||
<xsd:extension base="typens:A"> | ||
<xsd:sequence> | ||
<xsd:element name="y" type="xsd:anyType"/> | ||
</xsd:sequence> | ||
</xsd:extension> | ||
</xsd:complexContent> | ||
</xsd:complexType> | ||
</xsd:schema> | ||
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:abt"> | ||
<xsd:complexType name="At"> | ||
<xsd:sequence> | ||
<xsd:element name="x" type="xsd:anyType"/> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="Bt"> | ||
<xsd:complexContent> | ||
<xsd:extension base="typens:A"> | ||
<xsd:sequence> | ||
<xsd:element name="y" type="xsd:anyType"/> | ||
</xsd:sequence> | ||
</xsd:extension> | ||
</xsd:complexContent> | ||
</xsd:complexType> | ||
</xsd:schema> | ||
|
||
</types> | ||
<message name="f"> | ||
<part name="fInput" type="xsd:anyType"/> | ||
</message> | ||
<message name="fResponse"> | ||
<part name="fReturn" type="typens:A"/> | ||
</message> | ||
<portType name="abServerPortType"> | ||
<operation name="f"> | ||
<input message="typens:f"/> | ||
<output message="typens:fResponse"/> | ||
</operation> | ||
</portType> | ||
<binding name="abServerBinding" type="typens:abServerPortType"> | ||
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> | ||
<operation name="f"> | ||
<soap:operation soapAction="urn:abServerAction"/> | ||
<input> | ||
<soap:body namespace="urn:ab" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</input> | ||
<output> | ||
<soap:body namespace="urn:ab" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</output> | ||
</operation> | ||
</binding> | ||
<service name="abService"> | ||
<port name="abServerPort" binding="typens:abServerBinding"> | ||
<soap:address location="http://localhost/abServer.php"/> | ||
</port> | ||
</service> | ||
</definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--TEST-- | ||
SOAP Classmap 7: encoding of inherited objects with namespace and cache wsdl | ||
--EXTENSIONS-- | ||
soap | ||
--INI-- | ||
soap.wsdl_cache_enabled=1 | ||
--FILE-- | ||
<?php | ||
class A { | ||
public $x; | ||
function __construct($a){ | ||
$this->x = $a; | ||
} | ||
} | ||
class Attest { | ||
public $x; | ||
function __construct($a){ | ||
$this->x = $a; | ||
} | ||
} | ||
class B extends A { | ||
public $y; | ||
function __construct($a){ | ||
parent::__construct($a); | ||
$this->y = $a + 1; | ||
} | ||
} | ||
|
||
function f($input){ | ||
return new B(5); | ||
} | ||
|
||
class LocalSoapClient extends SoapClient { | ||
private $server; | ||
|
||
function __construct($wsdl, $options) { | ||
parent::__construct($wsdl, $options); | ||
$this->server = new SoapServer($wsdl, $options); | ||
$this->server->addFunction("f"); | ||
} | ||
|
||
function __doRequest($request, $location, $action, $version, $one_way = 0): ?string { | ||
ob_start(); | ||
$this->server->handle($request); | ||
$response = ob_get_contents(); | ||
ob_end_clean(); | ||
return $response; | ||
} | ||
} | ||
|
||
$client = new LocalSoapClient(__DIR__."/classmap007.wsdl", | ||
array('classmap'=>array('A'=>'A','{urn:abt}At'=>'Attest','B'=>'B'))); | ||
print_r($client->f(new Attest('test'))); | ||
print_r($client->f(new Attest('test'))); | ||
?> | ||
--EXPECT-- | ||
B Object | ||
( | ||
[x] => 5 | ||
[y] => 6 | ||
) | ||
B Object | ||
( | ||
[x] => 5 | ||
[y] => 6 | ||
) |
Oops, something went wrong.