This topic is locked
[SOLVED]

Webservices from NAV 2013R2 from PHPRunner

6/12/2021
PHPRunner General questions
D
dannyschaepdrijver author

I am facing next problem :
I want to call a webservice published by a NAV 2013R2 webservice by a php-code executed from phprunner.

PHP version : 7.2.3

Whenever I want to call, I get the next response failure

object(SoapFault)#2 (9) { ["message":protected]=> string(232) "SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://192.168.1.216:7077/NAVISION_TEST/WS/XXX/Codeunit/WS_FUNCTIONS' : failed to load external entity "http://192.168.1.216:7077/NAVISION_TEST/WS/XXX/Codeunit/WS_FUNCTIONS" " ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(32) "E:\Xampp\htdocs\bru_wms\test.php" ["line":protected]=> int(27) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(32) "E:\Xampp\htdocs\bru_wms\test.php" ["line"]=> int(27) ["function"]=> string(10) "SoapClient" ["class"]=> string(10) "SoapClient" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(74) "http://192.168.1.216:7077/NAVISION_TEST/WS/XXX/Codeunit/WS_FUNCTIONS" [1]=> array(5) { ["authentication"]=> int(0) ["login"]=> string(18) "SRVB-NAVT\adminSDT" ["password"]=> string(8) "SDT2015;" ["trace"]=> int(1) ["exception"]=> int(0) } } } } ["previous":"Exception":private]=> NULL ["faultstring"]=> string(232) "SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://192.168.1.216:7077/NAVISION_TEST/WS/XXX/Codeunit/WS_FUNCTIONS' : failed to load external entity "http://192.168.1.216:7077/NAVISION_TEST/WS/XXX/Codeunit/WS_FUNCTIONS" " ["faultcode"]=> string(4) "WSDL" }

Did anybody did this before me with success ?
If I call the webservice directly from my browser, I get a normal response.
Many thanks,
Danny

admin 6/12/2021

You need to provide more info and some screenshots. Where this error is happening? What is E:\Xampp\htdocs\bru_wms\test.php? What call the webservice directly from my browser?

fhumanes 6/12/2021

Hello:

This link is explained in this link to create a service communicated by WebServices and how to consume it.

https://fhumanes.com/blog/integracion/webservices-json/

It may help you build your code.

Greetings,
fernando

D
dannyschaepdrijver author 6/14/2021

This is the code called from php

<?php

if (extension_loaded('soap'))
{
// Request parameters :
// Exemple is a Nav Code unit GetSalesPrices, method GetPrice(CodPCustomerNo, CodPItemNo)
$NavUsername = "SRVB-NAVT\xxxxxx";
$NavAccessKey = "xxxxxxxx";

$CodeunitMethod = "GET_TESTINFO";
$params = array(
"Returncode" => "myreturncode",
);
// SOAP request header

;
$url = "http://192.168.1.216:7077/NAVISION_TEST/WS/xxxxxx/Codeunit/WS_FUNCTIONS";
$options = array(
'authentication' => SOAP_AUTHENTICATION_BASIC,
'login' => $NavUsername,
'password' => $NavAccessKey,
'trace' => 1,
'exception' => 0,
);
try
{
$client = new SoapClient($url, $options);
$soap_response = $client->__soapCall($CodeunitMethod, array('parameters' => $params));
echo "SOAP REQUEST SUCESS :";
var_dump($client->__getFunctions());
}
catch (SoapFault $soapFault)
{
echo "SOAP REQUEST FAILED :
";
var_dump($soapFault);

}

}
else
{
echo "Php SOAP extention is not available. Please enable/install it to handle SOAP communication.";
}

?>

admin 6/14/2021

I'm sorry, but how does this apply to PHPRunner?