Just a quick code snippet today. I was building some backend processes and I needed to interface with our MS Navision ERP system to get and set some values on finished good in our inventory as they came off the manufacturing line.
First some housekeeping is in order. You need to have your Navision Web Service configured to support NTLM. I won’t go into that here, but you can find some great walkthroughs on MS’s technet and elsewhere on the internet. Also, make sure you create a non-privileged windows account to use for sending your SOAP requests to the navision web service as it will be stored in your scripts. When I promote this to production, I will probably add a TLS layer on the web service as well.
#!/usr/bin/python
import suds
from suds.client import Client
from suds.transport.https import WindowsHttpAuthenticated
# Define our SUDS client for the Nav WS SOAP API
ntlm = WindowsHttpAuthenticated(username=’\\’, password=’hahahayouthoughtIdGiveYoumyPasswdLOL’)
url = ‘http://host:7047/DynamicsNAV/WS/companydb/Page/’
client = Client(url, transport=ntlm)
print (client) # this will return the methods and types available from the codeunit
In my case, I had a “Read” method to get information regarding a product.
try:
result = client.service.Read(‘ ‘, ‘ ‘, srlno)
return result
except suds.WebFault, e:
print e
except AttributeError, e:
print e
It seems that SUDS has an issue with Attribute ‘NoneType’. I’ve written about it here http://stackoverflow.com/questions/29856455/how-to-handle-python-suds-return-return-body0-children/29856907#29856907
This should be enough to get you on your way to integrating external systems with MS Navision 2009. It’s a great way to get away from having direct SQL access and implementing an n-tier architecture with API’s. Unfortunately, Navision 2009 web services is a SOAP API. I guess it could be worse.