NAV 2009 XMLPort with Web Services (VB.net example)
jwilder
Member Posts: 263
I am looking for a basic example of using an xmlport with web services. I have followed Freddy's Blog which does this with a Vista Gadget + J Script. So I am just looking for the simplest example of the vb.net code, I already have a codeunit + Functions + xmlport setup similar to the one in Freddy's Blog - Vista Gadget - My "Stuff". For an easy example I am just looking to return the results of the xmlport to a variable.
Jason Wilder
jwilder@stonewallkitchen.com
jwilder@stonewallkitchen.com
0
Comments
-
Sorry that I don't speak VB - but a simple C# sample can be found here (4 lines c# towards the end)
http://www.mibuso.com/forum/viewtopic.php?f=32&t=29557
Hopefully that helpsFreddy Kristiansen
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.0 -
Freddy thanks for your so far, I am almost there. I need a tiny bit more help with the visual studio code:
WSTest1.MyXMLCusts myXMLcusts = new WSTest1.MyXMLCusts();
test.GetXMLPort(ref myXMLcusts);
foreach (WSTest1.MyXMLCust myXMLcust in myXMLcusts.MyXMLCust)
Can you add the rest of the code for the initial connection? I think the test variable is the web serviceJason Wilder
jwilder@stonewallkitchen.com0 -
I got it! Using Freddy's example in this link ( http://www.mibuso.com/forum/viewtopic.php?f=32&t=29557 ) for the NAV Codeunit + XMLPort here is the VB.net code in Visual Studio:
Dim Test As New NAVWebservice.NAVCodeunit Test.UseDefaultCredentials = True Test.Url = "http://swk-lab2:7047/DynamicsNAV/WS/SWKTestU5/Codeunit/NAVCodeunit" Dim myXMLCusts As New NAVWebservice.MyXMLCustomers Test.GetXMLPort(myXMLCusts) For Each myXMLCust In myXMLCusts.MyXMLCustomer MsgBox(myXMLCust.No & " " & myXMLCust.Name) NextThanks Freddy!Jason Wilder
jwilder@stonewallkitchen.com0 -
and thanks for putting up the vb.net sample =D>Freddy Kristiansen
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.0 -
Hello everyone.
I was looking at your VB Code and I was wondering what I would need to change to be able to pass an XML file as a parameter to a function that had a data type of type file as opposed to XML Port?
I have a function called NewInvoice(VAR InvoiceXMLDoc : File). I want NewInvoice to be accessible via web services but I don't know much about VB and I need to test my NAV function works when called from another programming language.
I have tried but I am battling to understand the VB syntax and I cannot try any other language as I only have VB on my laptop (from Excel).
ANy help would be greatly apperciated.
](*,)0 -
Very interesting, I haven't tried passing back a file as a var parameter, but I have done this in a different way. Instead of using a File variable use BigText. I am workign on an example of this but basically do this:
1) Create an xmlport (make sure property Encoding is set to UTF-8)
2) Create a funcion in a codeunit that you will publish as a web service. Required Parameter is
Bigtext (make sure var is checked)
3) You'll need some Navision code like this:
TempBlob.Blob.CREATEOUTSTREAM(StreamOut)
YourXMLPort.SETDESTINATION(StreamOut);
YourXMLPort.EXPORT; //This fills the tempblob with your xmlfile
TempBlob.MODIFY;
TempBlob.Blob.CREATEINSTREAM(StreamIn);
BigText.READ(StreamIn); //This copys the xmlfile stored in the blob into the bigtext variable
Tempblob datatype record 99008535 temporary = yes
streamOut datatype Outstream
YourXMLPort datatype XMLPort ####?
StreamIn datatype InStream
BigText datatype BigText
Tell me if table 99008535 does not exist in your database. The trick behind this whole thing is to fill the BigText variable with whatever you want (Xml,csv file etc...) and pass it to your vb.net call.
The vb.net call just needs to pass a blank string into the bigtext parameter. It the end this string will contain your xmlfile.Jason Wilder
jwilder@stonewallkitchen.com0 -
Rather than looping through each element of the array, you can do the following to load it into a dataset (example is in c#):
public void BindNAVArray(NAVService.ARRAYOBJECT _ArrayObject) { DataSet ds = new DataSet(); XmlSerializer xmlSerializer = new XmlSerializer(_ArrayObject.GetType()); StringWriter stringWriter = new StringWriter(); xmlSerializer.Serialize(stringWriter, _ArrayObject); StringReader stringReader = new StringReader(stringWriter.ToString()); ds.ReadXml(stringReader); }0 -
I've been looking for something like that. Thanks, I will definitely try this out!Jason Wilder
jwilder@stonewallkitchen.com0
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
- 322 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