小编jed*_*ipt的帖子

在 PHP SoapClient 请求中更改命名空间?

我正在寻找一种方法来更改命名空间:“ns1”到“ret”,使用 SoapUI 测试以下 XML,并将命名空间设置为“ret”并且请求成功。我已经“谷歌搜索”,并在 SO 中搜索了其他相关问题的答案,但没有运气。所以,我有点不顾一切地想找到答案......

这是生成的要发送到请求的 XML:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://retailexpress.com.au/">
    <SOAP-ENV:Header>
        <ns1:ClientHeader>
            <ns1:ClientID>Random-hash-clientID</ns1:ClientID>
            <ns1:UserName>Username</ns1:UserName>
            <ns1:Password>Password</ns1:Password>
        </ns1:ClientHeader>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns1:CustomerGetBulkDetails>
            <ns1:LastUpdated>2000-01-01T00:00:00.000Z</ns1:LastUpdated>
            <ns1:OnlyCustomersWithEmails>1</ns1:OnlyCustomersWithEmails>
        </ns1:CustomerGetBulkDetails>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)

虽然,我们必须使用相同的命名空间 (ret) 请求似乎有点奇怪,但这就是它的方式......

这是用于生成上述内容的 PHP 代码:

    $rexHost = '<domain of retail express>';
    $rexApi = '<URI of retail express API / wsdl path>';
    $rexUser = 'Username';
    $rexPassword = 'Password';
    $rexApiClient = 'Random-hash-clientID';
    $rexApiHost = 'http://retailexpress.com.au/';

    $client = new SoapClient($rexHost.$rexApi, array('trace' => true));

    $auth = new stdClass();
    $auth->ClientID = $rexApiClient;
    $auth->UserName = $rexUser;
    $auth->Password …
Run Code Online (Sandbox Code Playgroud)

php xml soap laravel-4

2
推荐指数
1
解决办法
5042
查看次数

标签 统计

laravel-4 ×1

php ×1

soap ×1

xml ×1