web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Reading XML with HTTPS

(0) ShareShare
ReportReport
Posted on by 52

Hello Community,

We have an issue reading XML coming with SSL Certificate, with https URL. Example of the URL is like this : https://site.com/page.php?key=xxx&date=2018-07-15

This URL shows a page with XML structure. I can read and save it to table, if it comes with http and no ssl certificate. But when it comes with ssl https, it gives an exception like below:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
at System.Net.HttpWebRequest.GetResponse()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Dynamics.AX.ManagedInterop.ClrBridgeImpl.InvokeClrInstanceMethod(ClrBridgeImpl* , ObjectWrapper* objectWrapper, Char* pszMethodName, Int32 argsLength, ObjectWrapper** arguments, Boolean* argsAreByRef, Boolean* isException)

I read it with following code:

 System.Net.WebResponse              webResponse;
    System.Net.HttpWebRequest           httpWebRequest;
    System.Net.WebHeaderCollection      webHeaderCollection;
    System.IO.StreamReader              streamReader;
    System.IO.Stream                    stream;
    System.Exception                    netExcepn;
    str                                 xmlOut;
    XmlDocument                         xmlDocument;
    XmlNodeList                         xmlNodeList;
    XmlNode                             mainNode;
    XmlNode                             childNode;
    
    
    #define.ServiceTimeout(5000)
    #define.ServiceURL(xmlAddress)
    #define.mainNodeName('orders')
    #define.childNodeName('order')



    #define.HttpWebRequestMethod("GET")
    #define.HttpWebRequestContentType("application/xml")
    #define.HttpHeaderAuthorization("Authorization")


    if(this.validateURL(xmlAddress))
    {
        try
        {
        httpWebRequest          = System.Net.WebRequest::CreateHttp(#ServiceURL);
        httpWebRequest.set_Method(#HttpWebRequestMethod);
        httpWebRequest.set_ContentType(#HttpWebRequestContentType);
        httpWebRequest.set_Timeout(#ServiceTimeout);
        //httpWebRequest.set_ClientCertificates(
        webHeaderCollection     = httpWebRequest.get_Headers();
        webResponse             = httpWebRequest.GetResponse();
        stream                  = webResponse.GetResponseStream();
        streamReader            = new System.IO.StreamReader(stream);
        info("@QQL940");
        }
        catch(Exception::CLRError)
        {
            netExcepn = CLRInterop::getLastException();
            info(netExcepn.ToString());
        }
    }
    else
    {
        streamReader            = new System.IO.StreamReader(xmlAddress);
        info("@QQL941");
    }

    if(!sourceId)
    {
        checkFailed("@QQL946");
        return;
    }
    xmlOut                  = streamReader.ReadToEnd();


    xmlDocument             = XmlDocument::newXml(XMLOut);
    mainNode                = xmlDocument.selectSingleNode(#mainNodeName);
    xmlNodeList             = mainNode.selectNodes(#childNodeName);
    childNode               = xmlNodeList.nextNode();

    while (childNode)
    {
        this.parseXML(childNode);
        childNode               = xmlNodeList.nextNode();
    }

    info("@QQL942");
   // --------------------- READ FROM XML-----------------
}


Can you please help me to solve this problem.

Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Hi badiyev,

    Try to add this line before httpWebRequest = System.Net.WebRequest::CreateHttp(#ServiceURL)

    System.Net.ServicePointManager::set_SecurityProtocol(System.Net.SecurityProtocolType::Ssl3);
  • badiyev Profile Picture
    52 on at

    ievgen, thanks for your response, but this did not solve my problem :(

  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    You may try SecurityProtocolType::Tls12 or SecurityProtocolType::Tls or  SecurityProtocolType::Tls11 as well because It's obviously hard for me to tell what your web service expecting and what .Net version it is.

  • badiyev Profile Picture
    52 on at

    That did the trick for me, also, i have defined the certificate and showed the path to certificate in order Ax to understand which certificate should it use.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
GL-01081504-0 Profile Picture

GL-01081504-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans