我想知道如何使用soapclient函数在PHP中编写以下soap请求?
WSDL:https://test.edentiti.com/Registrations-Registrations/DynamicFormsService?wsdl
致电行动:
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:dyn="http://dynamicform.services.registrations.edentiti.com/">
> <soapenv:Header/> <soapenv:Body>
> <dyn:registerVerification>
> <accountId>ABCDEFGHIJKL</accountId>
> <password>1010101010</password>
> <ruleId>default</ruleId>
> <name>
> <givenName>John</givenName>
> <honorific></honorific>
> <middleNames></middleNames>
> <surname>Citizen</surname>
> </name>
> <email>john@edentiti.com</email>
> <currentResidentialAddress>
> <country>AUS</country>
> <postcode>2000</postcode>
> <state>NSW</state>
> <streetName>address</streetName>
> <streetNumber></streetNumber>
> <streetType></streetType>
> <suburb>city</suburb>
> </currentResidentialAddress>
>
> <generateVerificationToken>false</generateVerificationToken>
> </dyn:registerVerification> </soapenv:Body> </soapenv:Envelope>
我想知道如何在下面的函数中编写如何。
//Create the client object
$soapclient = new SoapClient('');
$params = array(...........);
$response = $soapclient->.......($params);
var_dump($response);
答案 0 :(得分:2)
您只需使用数据数组作为唯一参数调用registerVerification
方法:
$wsdl = 'https://test.edentiti.com/Registrations-Registrations/DynamicFormsService?wsdl';
$client = new SoapClient($wsdl);
$registerVerificationData = [
'accountId' => 'ABCDEFGHIJKL',
'password' => '1010101010',
'ruleId' => 'default',
'name' => [
'givenName' => 'John',
'honorific' => null,
'middleNames' => null,
'surname' => 'Citizen',
],
'email' => 'john@edentiti.com',
'currentResidentialAddress' => [
'country' => 'AUS',
'postcode' => '2000',
'state' => 'NSW',
'streetName' => null,
'streetNumber' => null,
'streetType' => null,
'suburb' => 'city',
],
'generateVerificationToken' => false,
];
$response = $client->registerVerification($registerVerificationData);
var_dump($response);
如果SOAP服务器要求定义null
属性,则可以在调用null
之前将所有SoapVar
值替换为registerVerification()
个实例:
array_walk_recursive($registerVerificationData, function (&$value) {
if ($value === null) {
$value = new SoapVar(null, XSD_ANYTYPE);
}
});