XML file - Consume Web Service

scott
Member Posts: 76
Hi all,
We have a client using XML to transmit their sales orders to a third party fullfillment warehouse. They developed a web service for us to use. Basically right after we create an XML file in Navsion, we have to link to the web service to consume it automatically, so their system can have orders right away. They don't want us to just send the XML file through email.
Does anyone have similar experience? What is the best way to accomplish this? They use .Net technology.
Thanks.
Scott
We have a client using XML to transmit their sales orders to a third party fullfillment warehouse. They developed a web service for us to use. Basically right after we create an XML file in Navsion, we have to link to the web service to consume it automatically, so their system can have orders right away. They don't want us to just send the XML file through email.
Does anyone have similar experience? What is the best way to accomplish this? They use .Net technology.
Thanks.
Scott
0
Comments
-
Some time in a near future perhaps the initiative at vip.navision.com will make this possible in a lean-mean way. In the meen time i think you will need to make some kind om COM wrapper for the web-client in order to be able to use it from within Navision0
-
I think SOAP is the best way to talk to the web services. I tried SOAP automation in Navision, but couldn't make it work. If somebody has used SOAP in Navision, please let me know. Thanks.0
-
I hope no one minds me bringing back an old post.
I have a client that would like to use Web Services to transmit sales orders and other information from another package to avoid using Biz Talk Server.
Does anyone know if this is possible? And if it is, it is a good idea or not?
I'm having a difficult time finding the information I need to determine this.
Thanks,
Mindi0 -
I have successfully communicated with a web-service from within Navision.
I can't give it for free, as a lot of hours where put into it. Let me find it from my toolbox and get back to you regarding the terms - that is, if you are interested.
It has been developed using Microsoft.NET. So the framework is required to be installed on the clients using it.0 -
I have now looked into my solution. It seems it may be more than you expect/need.
The webservice, that I communicate with delivevers both a stream of bytes containing an xml-response and a binary stream containing a bitmap.
So two responses are actually handled in my solution. This is not normal, I think!
It has been programmed as an automation server available in Navision as an Automation type variable. As the Navision programmer this is the interface you can use:
One property:
ServiceLocation := "http://1.2.3.4/Location/Service.asmx";
One method:
OK := SendRequest(XmlFileName, BinaryFileName);
So the property sets the location of the webservice, while the method tells the automation server where to store the xml and binary files for later use by Navision. Actually XmlFileName is also used for outgoing information to the webservice, the file is read by the automation server and send to the webservice as a parameter.
That's it!0 -
Here you are..
The easiest way to achive this is to use SOAP (in may humble opinion).
Below you will find whole codeunit, however - as I suppose -
you will also need Microsoft SOAP Toolkit 3.0. You can download it from
Microsoft website - I'm sure you'll find it.
...and below below there is also some specification stuff for this example to work.
have fun!
******************************************************
OBJECT Codeunit 50030 WebService
{
OBJECT-PROPERTIES
{
Data=04-12-09;
Godzina=[ 1:43:37];
Zmodyfikowany=Tak;
Lista wersji=;
}
PROPERTIES
{
OnRun=BEGIN
CallWebService;
END;
}
CODE
{
VAR
DOMNode@1101417012 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v4.0'.IXMLDOMNode";
SoapHttpConn@1101417000 : Automation "{91147A58-DFE4-47C0-8E76-987FC1A6001B} 3.0:{0AF40C53-9257-11D5-87EA-00B0D0BE6479}:'Microsoft Soap Type Library v3.0'.HttpConnector30";
SoapSerialize@1101417001 : Automation "{91147A58-DFE4-47C0-8E76-987FC1A6001B} 3.0:{B76585B0-9257-11D5-87EA-00B0D0BE6479}:'Microsoft Soap Type Library v3.0'.SoapSerializer30";
XMLDom@1101417002 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{F5078F32-C551-11D3-89B9-0000F81FE221}:'Microsoft XML, v4.0'.DOMDocument30";
DOMElement@1101417003 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{2933BF86-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v4.0'.IXMLDOMElement";
PROCEDURE CallWebService@1101417001();
BEGIN
IF ISCLEAR(SoapHttpConn) THEN
CREATE(SoapHttpConn);
SoapHttpConn.Property('EndPointURL','http://localhost:8080/NewFile.asmx');
SoapHttpConn.Connect;
SoapHttpConn.Property('SoapAction','http://tempuri.org/Add');
SoapHttpConn.BeginMessage;
IF ISCLEAR(SoapSerialize) THEN
CREATE(SoapSerialize);
SoapSerialize.Init(SoapHttpConn.InputStream);
SoapSerialize.StartEnvelope('','STANDARD');
SoapSerialize.StartBody;
SoapSerialize.WriteXml('<Add xmlns="http://tempuri.org/"><a>2</a><b>3</b></Add>');
SoapSerialize.EndBody;
SoapSerialize.EndEnvelope;
SoapHttpConn.EndMessage;
IF ISCLEAR(XMLDom) THEN
CREATE(XMLDom);
XMLDom.async := FALSE;
XMLDom.load(SoapHttpConn.OutputStream);
DOMElement := XMLDom.documentElement;
DOMNode := DOMElement.selectSingleNode('.//AddResult');
MESSAGE(DOMNode.text);
END;
EVENT XMLDom@1101417002::ondataavailable@198();
BEGIN
END;
EVENT XMLDom@1101417002::onreadystatechange@-609();
BEGIN
END;
BEGIN
{
Microsoft SOAP Toolkit 3.0
Wojciech Lukowski
MBS Navision Junior Consultant
wojciech.lukowski@NOSPAM.it.integro.pl
IT.integro POLAND, MBS Partner
}
END.
}
}
********************************************************
Below below part:
example GENERATES:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
- <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
- <SOAP-ENV:Body>
- <Add xmlns="http://tempuri.org/">
<a>2</a>
<b>3</b>
</Add>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
example RECEIVES:
<?xml version="1.0" encoding="utf-8" ?>
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap:Body>
- <AddResponse xmlns="http://tempuri.org/">
<AddResult>5</AddResult>
</AddResponse>
</soap:Body>
</soap:Envelope>
WEBSERVICE FORMAT
REQUEST
POST /NewFile.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Add"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Add xmlns="http://tempuri.org/">
<a>int</a>
<b>int</b>
</Add>
</soap:Body>
</soap:Envelope>
and RESPONSE
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddResponse xmlns="http://tempuri.org/">
<AddResult>int</AddResult>
</AddResponse>
</soap:Body>
</soap:Envelope>
WEBSERVICE IMPLEMENTATION - just an example - what you do inside it's your own business
<%@ WebService language="VB" class="classTest" %>
Imports System
Imports System.Web.Services
Imports System.Xml.Serialization
Public Class classTest
<WebMethod> Public Function Add(a As Integer, b As Integer) As Integer
Return a + b
End Function
End Class
regards,
Wojciech Lukowski
MBS Consultant0 -
I'm also interested in sending a file (text file) from navision to a webserver.
Since Navision 4.0 is now using the .NET framework, I guess SOAP solution is obsolete. Is there now another and even better a simpler way to achieve that?
thanks0 -
Hi hylafax,
I have tried your code for connecting to third party web service and retreiving data from xml file
It worked for me...
Thanks a lot
Regards
Dilip.0 -
Thank you for the code example. I imported your codeunit into NAV but when I try run it i get this error:
Call to member endmessage failed. Connector returned the following error message:
Connector:Connection failed or server refused connection (request might exceed MaxPostSize).
Any ideas? :-k0 -
hylafax, you are great!
It was the clearest and simplest solution I have ever met. Thank you for your share!
@admin: I suggest that thread to be transferred to "tips and tricks" section.
RegardsCem Karaer @ Pargesoft
Dynamics NAV Developer since 20050
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