$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(); }
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"
$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(); }
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
Comments
I would suggest to use HTTPRequest function.
http://php.net/manual/en/httprequest.send.php
There are many examples in NAV2009 that use HTTPRequest to connect to NAV web services.
e.g.
http://forums.asp.net/t/1676425.aspx?Change+hard+coded+HttpRequest+to+use+consumed+web+service
The idea is, you build your XML message as a text string and you send it to server with HTTPRequest .
The first message woudl be to authenticate yourself in NAV the second message can be your request.
You can use e.g. Fiddler to find out the structure of the XML message that needs to be sent to NAV.
Also take a look at this blog
http://blogs.msdn.com/b/freddyk/archive/2010/01/19/connecting-to-nav-web-services-from-php.aspx
Good luck it would be really nice to see that NAV Web Services can be accessed from Debian.
I hope this helps
Thanks.