Receiving SOAP Messages in NAV2009

iansilvers
Member Posts: 38
I hope someone can give me a bit of a help here. I have a customer who is looking to interface their NAV2009 SP1 system with an external warehousing application. We are dealing with SOAP documents, and I have to send messages about items, and orders to the warehouse, and receive back order despatch messages, stock balances etc from the warehouse. I am able to send the outbound documents to external web service without any problems, however, I am struggling to get the return messages back into NAV.
A sample inbound XML message that I am trying to bring into NAV looks like
I have one codeunit in NAV which is exposed as a web service to handle the receipt of messages. Within the codeunit I have a function for each message - in this case a function called StockAdjustmentMessage, with an XMLPort as the only parameter to receive the stockAdjustment content of the XML message.
When I try to access this using a simple .NET program doing a POST of the SOAP message, I am getting a 500 message, and the application event log on the server reports "Parameter stockAdjustment in method StockAdjustmentMessage in service ReflexInbound is null!"
Here is the code for my test program
The question is how do I get the actual message body into NAV? I have been working on this for a few days, and do not seem to be making any headway. Any help is greatly appreciated.
A sample inbound XML message that I am trying to bring into NAV looks like
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ref1="http://localhost/navision.wsdl"> <SOAP-ENV:Body> <ref1:StockAdjustmentMessage> <stockAdjustment> <itemCode>ITEM3</itemCode> <quantityAdjusted>-330</quantityAdjusted> <reasonCode>QA</reasonCode> </stockAdjustment> </ref1:StockAdjustmentMessage> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
I have one codeunit in NAV which is exposed as a web service to handle the receipt of messages. Within the codeunit I have a function for each message - in this case a function called StockAdjustmentMessage, with an XMLPort as the only parameter to receive the stockAdjustment content of the XML message.
PROCEDURE StockAdjustmentMessage@1000000008(stockAdjustment@1000000000 : XMLport 50001) OK : Boolean; BEGIN OK := stockAdjustment.IMPORT; END;
When I try to access this using a simple .NET program doing a POST of the SOAP message, I am getting a 500 message, and the application event log on the server reports "Parameter stockAdjustment in method StockAdjustmentMessage in service ReflexInbound is null!"
Here is the code for my test program
static void Main(string[] args) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(@"c:\StockAdjustment.xml"); HttpWebRequest request; HttpWebResponse response; Stream responseStream; StreamWriter writer; StreamReader reader; string url = @"http://iis:7047/DynamicsNAV/WS/TestCompany/Codeunit/ReflexInbound"; request = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url)); request.ProtocolVersion = new Version(1, 1); request.Method = "POST"; request.ContentType = @"application/xml; charset=utf-8"; request.Accept = "text/xml"; request.UseDefaultCredentials = true; request.Headers.Add("SOAPAction", @"StockAdjustmentMessage"); writer = new StreamWriter(request.GetRequestStream(), Encoding.UTF8); writer.Write(xmlDoc.OuterXml); writer.Flush(); writer.Close(); response = (HttpWebResponse)request.GetResponse(); responseStream = response.GetResponseStream(); string response_result = string.Empty; if (responseStream != null) { reader = new StreamReader(responseStream); response_result = reader.ReadToEnd(); }
The question is how do I get the actual message body into NAV? I have been working on this for a few days, and do not seem to be making any headway. Any help is greatly appreciated.
0
Best Answer
-
Problem resolved. Turns out to be with the Namespaces on the XML document.0
Answers
-
Problem resolved. Turns out to be with the Namespaces on the XML document.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