我正在使用非wsdl soap调用Web服务,我可以构建请求,但是我需要在信封体内设置模式版本。
我可以使用PHP SoapClient构建此请求:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://schemas.discovery.co.za/vitality">
<env:Body>
<ns1:UsageEligibilityRequest>
<ns1:RequestingEntityNumber>12345678</ns1:RequestingEntityNumber>
<ns1:Entities>
<ns1:EntityNumber>12345678</ns1:EntityNumber>
<ns1:DateOfBirth>1980-01-01</ns1:DateOfBirth>
<ns1:Gender>M</ns1:Gender>
<ns1:FirstInitial>H</ns1:FirstInitial>
</ns1:Entities>
</ns1:UsageEligibilityRequest>
</env:Body>
</env:Envelope>
但是我需要这一行:
<ns1:UsageEligibilityRequest>
是
<ns1:UsageEligibilityRequest schemaVersion="1.0">
不确定如何使用内置函数/选项在PHP中执行此操作,并且对Google来说似乎很难。
这是使用如下代码构建的:
$client->__soapCall('UsageEligibilityRequest', array($options));
感谢。
答案 0 :(得分:0)
有两种方法可以做到这一点
$requestingUser = 12345678;
$entityNumber = 12345678;
$dateOfBirth = '1980-01-01';
$gender = 'M';
$firstInitial = 'H';
使用SoapVar,如:
$paramsSOAPVar = new SoapVar('<ns1:UsageEligibilityRequest schemaVersion="1">
<ns1:RequestingEntityNumber>' . $requestingUser. '</ns1:RequestingEntityNumber>
<ns1:Entities>
<ns1:EntityNumber>' . $entityNumber. '</ns1:EntityNumber>
<ns1:DateOfBirth>' .$requestingUser. '</ns1:DateOfBirth>
<ns1:Gender>' .$gender. 'M</ns1:Gender>
<ns1:FirstInitial>' .$firstInitial. '</ns1:FirstInitial>
</ns1:Entities>
</ns1:UsageEligibilityRequest>', XSD_ANYXML);
设置参数数组:
$params = array(
'schemaVersion' => 1,
'RequestingEntityNumber' => $requestingUser,
'Entities' => array(
'EntityNumber' => $entityNumber,
'DateOfBirth' => $dateOfBirth,
'Gender' => $gender,
'FirstInitial' => $firstInitial
)
);