Nav to Nav Webservice

prototyper
Member Posts: 70
Is it possible to have Navision call another Navisions webservice?
I have the following code but I am getting a SQL Logon permission error in the resulting xml.
Will I have to use a C# program with credentials to overcome this ?
I have the following code but I am getting a SQL Logon permission error in the resulting xml.
Will I have to use a C# program with credentials to overcome this ?
CREATE(locautSoapHttpConnector); CREATE(locautSoapSerializer); CREATE(locautXmlDoc); locautSoapHttpConnector.Property('EndPointURL', 'http://servername:7047/DynamicsNAV/ws/coduenit/'); locautSoapHttpConnector.Connect; //WSDL('7047'); locautSoapHttpConnector.Property('AuthUser', 'Adminuserid'); locautSoapHttpConnector.Property('AuthPassword', 'Adminpsw'); locautSoapHttpConnector.Property('Timeout', 5 * 1000); locautSoapHttpConnector.Property('SoapAction','http://servername:7047/DynamicsNAV/ws/coduenit/thefunction'); locautSoapHttpConnector.BeginMessage; locautSoapSerializer.Init(locautSoapHttpConnector.InputStream); locautSoapSerializer.startEnvelope('SOAP','STANDARD'); locautSoapSerializer.startBody; locautSoapSerializer.startElement('Type'); locautSoapSerializer.writeString(FORMAT(Type)); locautSoapSerializer.endElement; locautSoapSerializer.startElement('ID'); locautSoapSerializer.writeString(FORMAT(ID)); locautSoapSerializer.endElement; locautSoapSerializer.endBody; locautSoapSerializer.endEnvelope; locautSoapHttpConnector.EndMessage; locautXmlDoc.load(locautSoapHttpConnector.OutputStream); locautXmlDoc.save('c:\temp\tempOut.xml');
Sleep on it... The best solutions come at 2am
0
Comments
-
yes using windows authentication. The user is not a database user (not sure if that makes any difference)Sleep on it... The best solutions come at 2am0
-
I'am not sure but I think when you set a user with locautSoapHttpConnector.Property('AuthUser',... this can't be used with a windows user!
if the user is the one your logged on then don't use the "auth user" propertys, if it works like in c# then it automaticly uses your windows user for authentication.
otherwise if you need to specify the user by code, then i suggest to use a normal DB-user, such a user can be used for "AuthUser" Property.
Warning: I never done this in NAV but if it works the same as in c# (I think so) then this is the way to go.0 -
Thanks I did try it with a dbuser and received an instance create error message on the "EndMessage"
Any other suggestions ?Sleep on it... The best solutions come at 2am0 -
Thanks Dev.
I can connect to Navision using the Db user I was using.
Moving the Connect to after the user/psw gives the same issue as using a db user. IE an Instance create error on the EndMessage.
It appears as though it needs user/psw for NT authentication in the Connection to create the soap message.
Is there a separate property or way of passing in a user/psw through the EndPoint or Soapaction or indicate that it should run using window authentication and not db?Sleep on it... The best solutions come at 2am0 -
You can try with this value in the Soap Action and the code works for Web Method without parameters.
CLEAR(locautSoapHttpConnector); CLEAR(locautSoapSerializer); CLEAR(locautXmlDoc); CREATE(locautSoapHttpConnector); locautSoapHttpConnector.Property('EndPointURL','http://localhost:7047/DynamicsNAV/WS/Company/Codeunit/TestWebService'); locautSoapHttpConnector.Connect; locautSoapHttpConnector.Property('Timeout', 5 * 1000); locautSoapHttpConnector.Property('SoapAction','http://schemas.xmlsoap.org/disco/scl/HelloNAV'); locautSoapHttpConnector.BeginMessage; CREATE(locautSoapSerializer); locautSoapSerializer.Init(locautSoapHttpConnector.InputStream); locautSoapSerializer.startEnvelope('SOAP','STANDARD'); locautSoapSerializer.startBody; locautSoapSerializer.startElement('HelloNAV'); locautSoapSerializer.endElement; locautSoapSerializer.endBody; locautSoapSerializer.endEnvelope; locautSoapHttpConnector.EndMessage; locautXmlDoc.load(locautSoapHttpConnector.OutputStream); locautXmlDoc.save('C:\Temp\hellonav.xml');
but with parameters, I am again getting this message:<faultcode xmlns:a="urn:microsoft-dynamics-schemas/error">a:Microsoft.Dynamics.Nav.Service.WebServices.ServiceBrokerException</faultcode> <faultstring xml:lang="en-US">Parameter input in method HelloWorld in service TestWebService is null!</faultstring> - <detail> <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Parameter input in method HelloWorld in service TestWebService is null!</string> </detail>
the code used is:CLEAR(locautSoapHttpConnector); CLEAR(locautSoapSerializer); CLEAR(locautXmlDoc); paramText := 'Dynamics'; CREATE(locautSoapHttpConnector); locautSoapHttpConnector.Property('EndPointURL','http://localhost:7047/DynamicsNAV/WS/Company/Codeunit/TestWebService'); locautSoapHttpConnector.Connect; locautSoapHttpConnector.Property('Timeout', 5 * 1000); locautSoapHttpConnector.Property('SoapAction','http://schemas.xmlsoap.org/disco/scl/HelloWorld'); locautSoapHttpConnector.BeginMessage; CREATE(locautSoapSerializer); locautSoapSerializer.Init(locautSoapHttpConnector.InputStream); locautSoapSerializer.startEnvelope('SOAP','STANDARD'); locautSoapSerializer.startBody; xmlText := '<HelloWorld xmlns="http://schemas.xmlsoap.org/wsdl/soap/"><input>'+paramText+'</input></HelloWorld>'; locautSoapSerializer.writeXML(xmlText); locautSoapSerializer.endBody; locautSoapSerializer.endEnvelope; locautSoapHttpConnector.EndMessage; CREATE(locautXmlDoc); locautXmlDoc.load(locautSoapHttpConnector.OutputStream); locautXmlDoc.save('C:\Temp\helloworld.xml');
Please suggest0
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