MSXML.XMLHTTPRequest Replacement

NAVFuchsNAVFuchs Member Posts: 76
edited 2022-09-23 in NAV Three Tier
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"

Answers

  • ShaiHuludShaiHulud Member Posts: 228
    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.
Sign In or Register to comment.