Calling a NAV 2009 Webservice from Debian Apache/PHP

SyliaSylia Member Posts: 2
I've been trying, for a week now, to connect to a NAV 2009 (no NTLM) Web Service from PHP. I've tried a lot of solutions, even the NTLM ones, but none of it worked.

After trying all those solutions, I reverted to something simple (since i get the same errors anyway), hoping you could help me with that :

1/ Connecting to the webservice using the url
$user = "username";
$password ="password";
//$wsdlPath = 'http://adress:port/DynamicsNAV/WS/NAV_TEST/Codeunit/SalesOrder?wsdl';
$wsdlPath = 'http://'.$user.':'.$password.'@adress:port/DynamicsNAV/WS/NAV_TEST/Codeunit/SalesOrder?wsdl';

$options = array(
	'login' => $user,
	'password' => $password,
	'trace' => 1,
	'exceptions' => 1,
);
try {
	$client = new SoapClient($wsdlPath,$options);
	echo "SoapClient: OK.<br>";
} catch (Exception $e) { 
	echo "SoapClient: ".$e->getMessage()."<br>";
}

$fcs = $client->__getFunctions();
echo "<pre>";
var_dump($fcs);
echo "</pre>";

try {
	$res = $client->Fct_TEST();
	echo "Function Call: ".$res;
} catch (Exception $e) { 
	echo "Function Call: ".$e->getMessage();
}

Result :
SoapClient: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://user:password@adress:port/DynamicsNAV/WS/IEC_TEST/Codeunit/SalesOrder?wsdl' : failed to load external entity "http://user:password@adress:port/DynamicsNAV/WS/IEC_TEST/Codeunit/SalesOrder?wsdl" 


2/ Connecting to the webservice using the xml (retrieved manually from debian using KInit and curl commands)
$user = "username";
$password ="password";
$wsdlPath = 'result.xml';

$options = array(
	'login' => $user,
	'password' => $password,
	'trace' => 1,
	'exceptions' => 1,
);
try {
	$client = new SoapClient($wsdlPath,$options);
	echo "SoapClient: OK.<br>";
} catch (Exception $e) { 
	echo "SoapClient: ".$e->getMessage()."<br>";
}

$fcs = $client->__getFunctions();
echo "<pre>";
var_dump($fcs);
echo "</pre>";

try {
	$res = $client->Fct_TEST();
	echo "Function Call: ".$res;
} catch (Exception $e) { 
	echo "Function Call: ".$e->getMessage();
}

Result :
SoapClient: OK.

array(4) {
  [0]=>
  string(82) "Fct_CreateSaleHeader_Result Fct_CreateSaleHeader(Fct_CreateSaleHeader $parameters)"
  [1]=>
  string(76) "Fct_CreateSaleLine_Result Fct_CreateSaleLine(Fct_CreateSaleLine $parameters)"
  [2]=>
  string(79) "Fct_ReleaseDocument_Result Fct_ReleaseDocument(Fct_ReleaseDocument $parameters)"
  [3]=>
  string(46) "Fct_TEST_Result Fct_TEST(Fct_TEST $parameters)"
}

Function Call: Unauthorized

So I guess the issue is the authentication to the webservice, specifically with PHP. (Since it works fine authenticating with debian's shell)
Is there any solution to this ? I would take any idea at this point, no matter how far-fetched it is. [-o<

Thanks.

Comments

Sign In or Register to comment.