0

FindPersons - SOAP POST using PHP

How can i display in php the firstName, lastName and targetName from a SOAP Response?

Here's my simple php script

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "https://company.hosted.xmatters.com/api/services/xmatters-5.5.47.xmatters-5.5.47HttpSoap12Endpoint/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:sch=\"http://www.xmatters.com/webservices/schema#5.5.47\">\r\n soapenv:Header/\r\n soapenv:Body\r\n sch:FindPersons\r\n sch:userws-soaptesting/sch:user\r\n sch:passwordsoaptesting/sch:password\r\n sch:clientTimestamp/\r\n sch:clientIP/\r\n sch:clientOSUser/\r\n sch:company/\r\n sch:searchParameters\r\n sch:targetName/sch:targetName\r\n /sch:searchParameters\r\n /sch:FindPersons\r\n /soapenv:Body\r\n/soapenv:Envelope",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: text/plain",
),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}

7 comments

Please sign in to leave a comment.