Say that you have been given the following:
<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:int="http://thesite.com/"> <x:Header/> <x:Body> <int:authenticateLogin> <int:LoginId>12345</int:LoginId> </int:authenticateLogin> </x:Body> </x:Envelope>
and
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <authenticateLoginResponse xmlns="http://thesite.com/"> <authenticateLoginResult> <RequestStatus>true</RequestStatus> <UserName>003p0000006XKX3AAO</UserName> <BearerToken>Abcdef1234567890</BearerToken> </authenticateLoginResult> </authenticateLoginResponse> </s:Body> </s:Envelope>
Let's say that access to http://thesite.com/ indicates that the WSDL address is: http://thesite.com/PortalIntegratorService.svc?wsdl
$client = new SoapClient('http://thesite.com/PortalIntegratorService.svc?wsdl'); $result = $client->authenticateLogin(array('LoginId' => 12345)); if (!empty($result->authenticateLoginResult->RequestStatus) && !empty($result->authenticateLoginResult->UserName)) { echo 'The username is: '.$result->authenticateLoginResult->UserName; }
As you can see, the elements specified in XML are used in the PHP code, although the LoginId value can be changed.
Luke Wenke May 6 '16 at 9:10 a.m. 2016-05-06 09:10
source share