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)

Calling External WebService

(0) ShareShare
ReportReport
Posted on by 285

Hi ,

I am calling an external webservice , from navision , while I call the SOAP URL in WSDL Browser  and Insert the XML , its is working fine.

But while I call the Same XML request from Navision and hit the same SOAP URL then it gives this error

Microsoft Dynamics NAV
---------------------------

A call to System.Net.HttpWebRequest.GetResponse failed with this message: The remote server returned an error: (400) Bad Request.
---------------------------
OK
---------------------------

I am writing this Code


xml := xml.XmlDocument();
xml.Load('D:\'+'NewRequest3.XML');
XMLResponse := XMLResponse.XmlDocument();
CallShipmentRequest(xml,XMLResponse,'','');
XMLResponse.Save('D:\'+'Response.XML');


HttpWebRequest := HttpWebRequest.Create('netconnect.bluedart.com/.../WayBillGeneration.svc');

HttpWebRequest.UseDefaultCredentials := TRUE;
HttpWebRequest.Method := Method;
//HttpWebRequest.ContentType := TypeValue;
HttpWebRequest.ContentType := 'application/soap+xml; charset=utf-8'; //'text/xml; charset=utf-8'; //

//HttpWebRequest.Credentials

HttpWebRequest.PreAuthenticate := TRUE;
XMLRequest.Save(HttpWebRequest.GetRequestStream);

HttpWebResponse := HttpWebRequest.GetResponse;
IF HttpWebResponse.StatusCode = 200 THEN BEGIN
XMLResponse.Load(HttpWebResponse.GetResponseStream);
EXIT(TRUE);
END ELSE
XMLResponse.Load(HttpWebResponse.GetResponseStream);
EXIT(FALSE);

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    This is not an area where I have a lot of experience wokring with but these are often authentication issues.  

    Are the credentials that you are using for the WSDL browser the same as those that are used for the NST?  Remember that the code is being executed on the server and not on your machine.

  • Suggested answer
    RockwithNav Profile Picture
    8,637 Super User 2025 Season 2 on at

    You may check this link if anyhow it helps you.

    rockwithnav.wordpress.com/.../consume-net-webservice-dotnet-data-type

    In this part DotNetXmlHttp.Send .... if you are using NAV xmlport then make sure that Request XML is exactly the same as that of you were experiencing in the WSDL'S.

    Sometimes a Namespace or an attribute becomes hurdle while using NAV XMLPORT so you should crosscheck this once.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    I Believe that your HttpWebResponse  does not contain the correct response from the WSDL when you use "yourlink?wsdl". The reason is that your WSDL contains external XSD:

    XSD.jpg

    You can ask your web service provider if they can simplify your life and give you a SINGLEWSDL. If they can't, then you should handle it yourself. i.e. download the external schemas 'xsd' and concatenate them to get the full WSDL. You can ask also if the web service supports "yourlink?singlewsdl" (that will get you the full wsdl ==> I tried it for you and it fails ;)).

    Besides, I see that your wsdl contains <wsdl:part name="parameters" .../>. This may cause some headaches for you. I think that your web service provider should avoid to use name="parameters". Instead, they can use name="parameters1".

    You can search for these keywords "singlewsdl, external xsd, import xsd" in order to get more details (from experts, not me :))

    Check this article https://weblog.west-wind.com/posts/2009/Feb/12/WSDL-Imports-without-WSDLexe where the blogger resolved the problem using C#.

    I hope that will guide you to fully understand the issue and resolve it.

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