Invoking webservice from Navision

shettarvikas
Member Posts: 106
Hi All,
Can we invoke Web Service from Navision directly.
Scenario:
From Navision, we need to send some data to third party application through web service. In this regard, Can Navision call the web service of 3rd party application directly.
Request for help in this regard.
Thanks & regards,
Vikas
Can we invoke Web Service from Navision directly.
Scenario:
From Navision, we need to send some data to third party application through web service. In this regard, Can Navision call the web service of 3rd party application directly.
Request for help in this regard.
Thanks & regards,
Vikas
0
Comments
-
Hello Vikas,
Yes we can
Here is an out of the box working example (call a webservice for validating a VAT No.)..
Dependencies: MS SOAP Toolkit 3.0.
WSDL: http://ec.europa.eu/taxation_customs/vi ... tPort?wsdlOBJECT Codeunit 99901 VAT Check { OBJECT-PROPERTIES { Date=23-01-08; Time=13:27:36; Modified=Yes; Version List=SML; } PROPERTIES { OnRun=BEGIN IF ISCLEAR(Connector) THEN CREATE(Connector); //Connector.Property('ProxyServer','isaserver'); //Connector.Property('ProxyPassword','proxypass'); //Connector.Property('ProxyUser','username'); Connector.Property('EndPointURL','http://ec.europa.eu/taxation_customs/vies/api/checkVatPort?wsdl'); Connector.Connect; Connector.Property('SoapAction','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Connector.BeginMessage; CREATE(Serializer); Serializer.Init(Connector.InputStream); Serializer.StartEnvelope('','STANDARD','utf-16'); Serializer.StartBody('STANDARD'); Serializer.StartElement('checkVat','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Serializer.StartElement('countryCode','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Serializer.WriteString('GB'); Serializer.EndElement; Serializer.StartElement('vatNumber','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Serializer.WriteString('704767477'); Serializer.EndElement; Serializer.EndElement; Serializer.EndBody; Serializer.EndEnvelope; Connector.EndMessage; IF ISCLEAR(XMLDOM) THEN CREATE(XMLDOM); XMLDOM.load(Connector.OutputStream); XMLNode := XMLDOM.selectSingleNode('//valid'); IF NOT ISCLEAR(XMLNode) THEN MESSAGE(XMLNode.text); XMLDOM.save('c:\vat.xml'); CLEAR(XMLDOM); CLEAR(Connector); END; } CODE { VAR Serializer@1000000000 : Automation "{91147A58-DFE4-47C0-8E76-987FC1A6001B} 3.0:{B76585B0-9257-11D5-87EA-00B0D0BE6479}:'Microsoft Soap Type Library v3.0'.SoapSerializer30"; Connector@1000000004 : Automation "{91147A58-DFE4-47C0-8E76-987FC1A6001B} 3.0:{0AF40C53-9257-11D5-87EA-00B0D0BE6479}:'Microsoft Soap Type Library v3.0'.HttpConnector30"; XMLDOM@1000000001 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.DOMDocument"; XMLNode@1000000003 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode"; EVENT XMLDOM@1000000001::ondataavailable@198(); BEGIN END; EVENT XMLDOM@1000000001::onreadystatechange@-609(); BEGIN END; BEGIN END. } }
Met vriendelijke groet, best regards,
Rvduuren0 -
Great example. It solved my problem. Any chance to get .NET example?0
-
bostjanl wrote:Great example. It solved my problem. Any chance to get .NET example?
Sure, Navision 4 ReportingServices 2005 is based on webservicesMet vriendelijke groet, best regards,
Rvduuren0 -
Hi,
I installed SOAP Toolkit v3.0, but when the create on the connector is invoked, i get this one:--------------------------- Microsoft Business Solutions-Navision --------------------------- This message is for C/AL programmers: Could not create an instance of the OLE control or Automation server identified by GUID={91147A58-DFE4-47C0-8E76-987FC1A6001B} 3.0:{0AF40C52-9257-11D5-87EA-00B0D0BE6479}:'Microsoft Soap Type Library v3.0'.SoapConnector30. Check that the OLE control or Automation server is correctly installed and registered. --------------------------- OK ---------------------------
Any ideas ?
This is the code i am using:if ISCLEAR(locautSoapHttpConnector) then CREATE(locautSoapHttpConnector); locautSoapHttpConnector.Property('EndPointURL', 'http://srv056/Holidays/Services.asmx'); locautSoapHttpConnector.Connect; //locautSoapHttpConnector.Property('AuthUser', 'User'); //locautSoapHttpConnector.Property('AuthPassword', 'Password'); locautSoapHttpConnector.Property('Timeout', 5 * 1000); locautSoapHttpConnector.Property('SoapAction','http://Holidays/Services/GetDayInfo'); locautSoapHttpConnector.BeginMessage;
0 -
Try with 'Microsoft XML, v3.0'.ServerXMLHTTP
SOAP uses XML.Name DataType Subtype Length XMLDocOut Automation 'Microsoft XML, v3.0'.DOMDocument XMLEnv Automation 'Microsoft XML, v3.0'.IXMLDOMNode XMLBody Automation 'Microsoft XML, v3.0'.IXMLDOMNode XMLAct Automation 'Microsoft XML, v3.0'.IXMLDOMNode XMLPar Automation 'Microsoft XML, v3.0'.IXMLDOMNode ADOStream Automation 'Microsoft ActiveX Data Objects 2.8 Library'.Stream XMLDomElement Automation 'Microsoft XML, v3.0'.IXMLDOMElement XMLHTTP Automation 'Microsoft XML, v3.0'.ServerXMLHTTP SOAP(URL : Text[150];Action : Text[30];TicketProviderID : Code[20];EventID : Code[20];EventProvider : Record "Event Ticket Provider") : .... CLEAR(XMLDocOut); CLEAR(XMLEnv) ; CLEAR(XMLBody) ; CLEAR(XMLAct) ; CLEAR(XMLPar) ; CLEAR(ADOStream) ; CREATE(ADOStream) ; ADOStream.Type := 1 ; ADOStream.Open ; CREATE(XMLDocOut); XMLDOMManagement.SetNormalCase; XMLProccesingInst := XMLDocOut.createProcessingInstruction('xml','version=''1.0'' encoding=''utf-8'''); XMLDocOut.appendChild(XMLProccesingInst); XMLEnv := XMLDocOut.createElement('soap:Envelope') ; XMLDocOut.appendChild(XMLEnv); XMLDOMManagement.AddAttribute(XMLEnv,'xmlns:soap','http://schemas.xmlsoap.org/soap/envelope/') ; XMLDOMManagement.AddAttribute(XMLEnv,'xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance') ; XMLDOMManagement.AddAttribute(XMLEnv,'xmlns:xsd','http://www.w3.org/2001/XMLSchema') ; XMLDomElement := XMLDocOut.documentElement ; XMLBody := XMLDocOut.createElement('soap:Body') ; XMLDomElement.appendChild(XMLBody) ; XMLAct := XMLDocOut.createElement(Action) ; XMLBody.appendChild(XMLAct) ; XMLPar := XMLDocOut.createNode(1,'language','') ; XMLPar.text := TicketProviders.Language ; XMLAct.appendChild(XMLPar) ; XMLPar := XMLDocOut.createNode(1,'userName','') ; XMLPar.text := TicketProviders."User Name" ; XMLAct.appendChild(XMLPar) ; XMLPar := XMLDocOut.createNode(1,'passWord','') ; XMLPar.text := TicketProviders.Password ; XMLAct.appendChild(XMLPar) ; SendSOAP(URL,URItemp+Action) ; SendSOAP(SOAPURL : Text[150];SOAPAction : Text[150]) CREATE(XMLHTTP) ; XMLHTTP.open('POST',SOAPURL,FALSE) ; XMLHTTP.setRequestHeader('Content-Type', 'text/xml; charset=utf-8') ; ...
0 -
I would prefer xmlhttp instead of soap toolkit, because soap toolkit reached end of life and soap toolkit has to be registered on each workstation, whereas xmlhttp is part of the msxml6.dll and part of almost every current windows installation:
Here's a very helpful example showing both ways.
http://www.mibuso.com/dlinfo.asp?FileID=539
Hope this helps
Thomas0 -
This is complete different from the code above then?
It seemed to have worked for others.0 -
I have worked quite a lot with webservices and using code as used in the provided link worked best. Some time ago I have also used soap toolkit, but it is now end of life now. Of course, soap toolkit still works.0
-
rvduuren wrote:Hello Vikas,
Yes we can
Here is an out of the box working example (call a webservice for validating a VAT No.)..
Dependencies: MS SOAP Toolkit 3.0.
WSDL: http://ec.europa.eu/taxation_customs/vi ... tPort?wsdlOBJECT Codeunit 99901 VAT Check { OBJECT-PROPERTIES { Date=23-01-08; Time=13:27:36; Modified=Yes; Version List=SML; } PROPERTIES { OnRun=BEGIN IF ISCLEAR(Connector) THEN CREATE(Connector); //Connector.Property('ProxyServer','isaserver'); //Connector.Property('ProxyPassword','proxypass'); //Connector.Property('ProxyUser','username'); Connector.Property('EndPointURL','http://ec.europa.eu/taxation_customs/vies/api/checkVatPort?wsdl'); Connector.Connect; Connector.Property('SoapAction','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Connector.BeginMessage; CREATE(Serializer); Serializer.Init(Connector.InputStream); Serializer.StartEnvelope('','STANDARD','utf-16'); Serializer.StartBody('STANDARD'); Serializer.StartElement('checkVat','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Serializer.StartElement('countryCode','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Serializer.WriteString('GB'); Serializer.EndElement; Serializer.StartElement('vatNumber','urn:ec.europa.eu:taxud:vies:services:checkVat:types'); Serializer.WriteString('704767477'); Serializer.EndElement; Serializer.EndElement; Serializer.EndBody; Serializer.EndEnvelope; Connector.EndMessage; IF ISCLEAR(XMLDOM) THEN CREATE(XMLDOM); XMLDOM.load(Connector.OutputStream); XMLNode := XMLDOM.selectSingleNode('//valid'); IF NOT ISCLEAR(XMLNode) THEN MESSAGE(XMLNode.text); XMLDOM.save('c:\vat.xml'); CLEAR(XMLDOM); CLEAR(Connector); END; } CODE { VAR Serializer@1000000000 : Automation "{91147A58-DFE4-47C0-8E76-987FC1A6001B} 3.0:{B76585B0-9257-11D5-87EA-00B0D0BE6479}:'Microsoft Soap Type Library v3.0'.SoapSerializer30"; Connector@1000000004 : Automation "{91147A58-DFE4-47C0-8E76-987FC1A6001B} 3.0:{0AF40C53-9257-11D5-87EA-00B0D0BE6479}:'Microsoft Soap Type Library v3.0'.HttpConnector30"; XMLDOM@1000000001 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.DOMDocument"; XMLNode@1000000003 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode"; EVENT XMLDOM@1000000001::ondataavailable@198(); BEGIN END; EVENT XMLDOM@1000000001::onreadystatechange@-609(); BEGIN END; BEGIN END. } }
Hi there rvduuren,
I am trying to learn by example, but in this case the WDSL has changed address. I thought I could just use your code, and substitute the new address, but it didn't work. Do you have some suggestions on what else needs to be fixed for Navision to communicate with it?
The new address is now: http://ec.europa.eu/taxation_customs/vi ... rvice.wsdl
Seems same parameters in my eyes, countrycode and vatnumber.
I have used the same webservice in a VB.NET + VBA Excel Solution, but Navision does not give me the toolbox to automatically setup the connection
Cheers,
pedgaard0
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