Calling a NAV 2009 Webservice from Debian Apache/PHP

Sylia
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
Result :
2/ Connecting to the webservice using the xml (retrieved manually from debian using KInit and curl commands)
Result :
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.
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.
0
Comments
-
Hi,
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.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions