0
votes

I am trying to use PHP to connect to ServiceNow and retrieve incident records.

I tried to use the code below but somehow I receive errors:

<?php
$credentials = array('login'=>'user', 'password'=>'pass');
$client = new SoapClient("https://blah.com/incident.do?WSDL", $credentials);
$params = array('param1' => 'value1', 'param1' => 'value1');
$result = $client->__soapCall('getRecords', array('parameters' => $params));
// result array stored in $result->getRecordsResult
?>

I am always getting:

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https : // blah . service-now . com / incident.do?WSDL' : failed to load external entity "https : // blah . service-now.com / incident.do?WSDL" in /var/www/index.php:3 Stack trace: #0 /var/www/index.php(3): SoapClient->SoapClient('https://blah.ser...', Array) #1 {main} thrown in /var/www/index.php on line 3

Of course I use the subdomain I want instead of blah. But let's assume it's blah.

Please help me. Is this code ok? Where do I place my username? On the user area? or in the login area? What about param1 and value1, which one of these do I need to change?

Yes, I have permission to do this on my servicenow instance, I can do other things regarding soap and wsdl.

1
Make sure the openssl PHP module is installed and enabledrjdown
Is it also acceptable if I test through this site? runnable.com/UovXqHcwNjgVAAGV/…Malbordio
Make sure you can actually get it over http using basic auth by using something like curl: curl -v 'USER:[email protected]/incident.do?WSDL'Joey
Yes, WSDL is active on my service-now instance. I can get results from it.Malbordio
I mean, literally go to your terminal, run a curl -v to that example URL template I provided and paste back the results. There's a good chance of getting some meaningful diagnostic information.Joey

1 Answers

0
votes

goto "System Properties" -> "Web Services" and make sure that "Require authorization for incoming WSDL requests." ist set to NO

If this flag is set to Yes you will not be able to directly create a SoapClient within PHP the way you described it.