Skip to main content
Post a question

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Calling External WebService

Posted on 17 Jan 2017 09:32:43 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

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on 19 Jan 2017 at 23:05:51
    RE: Calling External WebService

    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.

  • Suggested answer
    RockwithNav Profile Picture
    RockwithNav 6,562 on 19 Jan 2017 at 09:28:30
    RE: Calling External WebService

    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
    Community Member Microsoft Employee on 19 Jan 2017 at 06:41:05
    RE: Calling External WebService

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans