Skip to content

Implement request #61495: SoapClient::__getTargetNamespace() #15794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ext/soap/soap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2688,6 +2688,15 @@ PHP_METHOD(SoapClient, __getTypes)
}
/* }}} */

PHP_METHOD(SoapClient, __getTargetNamespace)
{
ZEND_PARSE_PARAMETERS_NONE();
const sdl *sdl;
FETCH_THIS_SDL(sdl);
if (sdl && sdl->target_ns) {
RETURN_STRING(sdl->target_ns);
}
}

/* {{{ Returns last SOAP request */
PHP_METHOD(SoapClient, __getLastRequest)
Expand Down
2 changes: 2 additions & 0 deletions ext/soap/soap.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@ public function __getFunctions(): ?array {}
/** @tentative-return-type */
public function __getTypes(): ?array {}

public function __getTargetNamespace(): ?string {}

/** @tentative-return-type */
public function __getLastRequest(): ?string {}

Expand Down
7 changes: 6 additions & 1 deletion ext/soap/soap_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions ext/soap/tests/SoapClient/__getTargetNamespace.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
Request #61495 (SoapClient::__getTargetNamespace)
--EXTENSIONS--
soap
--INI--
soap.wsdl_cache_enabled=0
--FILE--
<?php
$client = new SoapClient(__DIR__.'/../bugs/bug28985.wsdl');
var_dump($client->__getTargetNamespace());

$client = new SoapClient(__DIR__.'/../no_target_ns.wsdl');
var_dump($client->__getTargetNamespace());

$client = new SoapClient(null, ['location' => 'http://tmp', 'uri' => 'http://tmp']);
var_dump($client->__getTargetNamespace());
?>
--EXPECT--
string(19) "http://tempuri.org/"
NULL
NULL
19 changes: 19 additions & 0 deletions ext/soap/tests/no_target_ns.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" ?>
<definitions
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<portType name="TestServicePortType">
<operation name="test"/>
</portType>

<binding name="TestServiceBinding" type="tns:TestServicePortType">
<operation name="test"/>
</binding>

<service name="TestService">
<port name="TestServicePort" binding="tns:TestServiceBinding">
<soap:address location="http://tmp" />
</port>
</service>
</definitions>
Loading