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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

External Web services Related Issue

(0) ShareShare
ReportReport
Posted on by

I have created a Simple Hello Word Web service on ASP.net and wanted to consume this Web service in Navision.
When I am calling this web service from Navision I am getting "root element is missing" Error.

Microsoft Dynamics NAV



A call to System.Xml.XmlDocument.Load failed with this message: Data at the root level is invalid. Line 1, position 1.


OK




I have written this code.

Url :='http://localhost:55172/WebService.asmx';
reqText := '' + 'HelloWorld' +
'';

// save request text in instream
TempBlob."Primary Key" := 1;
TempBlob.Blob.CREATEOUTSTREAM(ReqBodyOutStream);
ReqBodyOutStream.WRITE(reqText);
TempBlob.Blob.CREATEINSTREAM(ReqBodyInStream);



// run the WebServReqMgt functions to send the request
WebServReqMgt.SetGlobals(ReqBodyInStream,Url,Username,Password);
WebServReqMgt.DisableHttpsCheck;
WebServReqMgt.RUN;

// get the response
WebServReqMgt.SendRequestToWebService();

WebServReqMgt.GetResponseContent(RespBodyInStream);
ResponseXmlDoc := ResponseXmlDoc.XmlDocument;
ResponseXmlDoc.Load(RespBodyInStream);
MESSAGE(ResponseXmlDoc.InnerXml);
END;

Name DataType Subtype Length
Url Text
reqText Text
TempBlob Record TempBlob
ReqBodyOutStream OutStream
ReqBodyInStream InStream
Username Text
Password Text
RespBodyInStream InStream
WebServReqMgt Codeunit SOAP Web Service Request Mgt.
ResponseXmlDoc DotNet System.Xml.XmlDocument.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

these are the variables which i am using

*This post is locked for comments

I have the same question (0)
  • mmv Profile Picture
    11,471 on at

    Is your webservice working correctly on the web browser?

  • Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    Hi,

    I assume that there might be an encoding issue with your XML.

    Check this link: stackoverflow.com/.../why-data-at-the-root-level-is-invalid-line-1-position-1-for-xml-document

  • Community Member Profile Picture
    on at

    yes web services

     is working fine, even I am consuming that web service in another Dotnet Application , and that web service is showing the data on browser also.

  • Muhammad Arif Maseed Profile Picture
    782 on at

    have you solved this issue ???

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans