MSXML.XMLHTTPRequest Replacement

NAVFuchs
Member Posts: 77
Hi,
to challenge an update from NAV to BC I have to refactor the code, because some of the libaries doesn't exist anymore:
MSXML.DOMDocumentClass.'Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
MSXML.XMLHTTPRequest.'Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
MSXML.XMLHTTPRequestClass.'Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
How can I rewrite the code and which dotnet function/libaries can I use to replace and refactor the code.
...
XMLDoc := xmlDOMConstructor.DOMDocumentClass;
XMLDoc.async := false;
XMLDoc.load(XMLFileName);
XMLHTTP := XMLHTTPConstructor.XMLHTTPRequestClass;
XMLHTTP.open('POST', Request, false, '', '');
XMLHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
XMLHTTP.send(XMLDoc);
...
and...
... HTTPRequest := HTTPRequest.XMLHTTPRequestClass;
HTTPRequest.open('POST',Request,TRUE,'','');
HTTPRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
HTTPRequest.ToString();
HTTPRequest.send(Data);
...
Add:(23.09):
I changed to:
assembly(Microsoft.VisualStudio.Interop)
{
type(MSXML.XMLHTTPRequestClass; "XMLHTTPRequestClass")
{ }
type(MSXML.XMLHTTPRequest; "XMLHTTPRequest")
{ }
}
HTTPRequest: DotNet XMLHTTPRequest;
HTTPRequestClass: dotnet XMLHTTPRequestClass;
HTTPRequest := HTTPRequestClass.XMLHTTPRequestClass();
HTTPRequest.open('POST', Request, true, '', '');
HTTPRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
//HTTPRequest.ToString(); //Compiler Error
HTTPRequest.send(Data);
But I then get the following Compiler-Error:
Cannot implicitly convert type 'DotNet "MSXML.XMLHTTPRequestClass"' to 'DotNet "MSXML.XMLHTTPRequest"
to challenge an update from NAV to BC I have to refactor the code, because some of the libaries doesn't exist anymore:
MSXML.DOMDocumentClass.'Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
MSXML.XMLHTTPRequest.'Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
MSXML.XMLHTTPRequestClass.'Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
How can I rewrite the code and which dotnet function/libaries can I use to replace and refactor the code.
...
XMLDoc := xmlDOMConstructor.DOMDocumentClass;
XMLDoc.async := false;
XMLDoc.load(XMLFileName);
XMLHTTP := XMLHTTPConstructor.XMLHTTPRequestClass;
XMLHTTP.open('POST', Request, false, '', '');
XMLHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
XMLHTTP.send(XMLDoc);
...
and...
... HTTPRequest := HTTPRequest.XMLHTTPRequestClass;
HTTPRequest.open('POST',Request,TRUE,'','');
HTTPRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
HTTPRequest.ToString();
HTTPRequest.send(Data);
...
Add:(23.09):
I changed to:
assembly(Microsoft.VisualStudio.Interop)
{
type(MSXML.XMLHTTPRequestClass; "XMLHTTPRequestClass")
{ }
type(MSXML.XMLHTTPRequest; "XMLHTTPRequest")
{ }
}
HTTPRequest: DotNet XMLHTTPRequest;
HTTPRequestClass: dotnet XMLHTTPRequestClass;
HTTPRequest := HTTPRequestClass.XMLHTTPRequestClass();
HTTPRequest.open('POST', Request, true, '', '');
HTTPRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
//HTTPRequest.ToString(); //Compiler Error
HTTPRequest.send(Data);
But I then get the following Compiler-Error:
Cannot implicitly convert type 'DotNet "MSXML.XMLHTTPRequestClass"' to 'DotNet "MSXML.XMLHTTPRequest"
0
Answers
-
XmlDocument and HttpRequest, and their "families" are now standard types within AL. Look into those and refactor your code using those types.
If you insist on using .net types, you should know that due to Universal Code Initiative, all customers using code that's not Cloud-ready (using .net makes it not cloud-ready), will start getting "penalized" with something like $70 extra cost on their license the first year, increasing further the second year and so on.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