Hello Coders,
I have been trying the below Request and Response through the XML Automation in NAV 5.0 version but I am getting the following error.
Microsoft Dynamics NAV
This message is for C/AL programmers:
The call to member send failed. msxml3.dll returned the following message:
A connection with the server could not be established
OK
Request Params:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="
http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="urn:ServiceRequest" xmlns:xsd="
http://www.w3.org/2001/XMLSchema" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<tns:create_service_request_status>
<service_request_status>
<registration_number>MH-46-AP-4294</registration_number>
<vin>VAD23423SFSSSD</vin>
<dealer_code>ABC001</dealer_code>
<request_id>123332</request_id>
<action_name>Checkup</action_name>
<action_performed_at>2018-01-15</action_performed_at>
</service_request_status>
</tns:create_service_request_status>
</env:Body>
</env:Envelope>
Response:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="
http://www.w3.org/2001/XMLSchema" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="urn:ServiceRequest">
<soap:Body>
<tns:create_service_request_status_response>
<value xsi:type="xsd:string">Service request status saved.</value>
</tns:create_service_request_status_response>
</soap:Body>
</soap:Envelope>
For the above requirement I am writing the code as below. Please suggest where I am wrong and guide me through:
CLEAR(DealerCodeL);
CLEAR(MakeCodeL);
IF ISCLEAR(XMLDomRequestL) THEN
CREATE(XMLDomRequestL);
IF ISCLEAR(XMLDomResponseL) THEN
CREATE(XMLDomResponseL);
XMLPostL := Text001;
XMLPostL := XMLPostL + '<registration_number>MH-46-AP-4294</registration_number>';
XMLPostL := XMLPostL + '<vin>WBAEC57010WP50212</vin>';
XMLPostL := XMLPostL + '<dealer_code>31898</dealer_code>';
XMLPostL := XMLPostL + '<request_id>12345611851</request_id>';
XMLPostL := XMLPostL + '<action_name>Checkup</action_name>';
XMLPostL := XMLPostL + '<action_performed_at>2018-01-17</action_performed_at>';
XMLPostL := XMLPostL + Text002;
IF NOT XMLDomRequestL.loadXML(XMLPostL) THEN
ERROR(Text003);
IF ISCLEAR(XMLHTTPL) THEN
CREATE(XMLHTTPL);
DataExchangeSetupL.GET;
XMLHTTPL.setOption('2',13056);
XMLHTTPL.open('POST','
http://bmw.sodelsolutions.com/soap/action',FALSE);
XMLHTTPL.setRequestHeader('Content-Type','text/xml');
XMLHTTPL.setRequestHeader('SOAPAction', '
http://bmw.sodelsolutions.com/soap/action');
XMLHTTPL.send(XMLDomRequestL);
// XMLDomRequestL.save('C:\Users\mehdis\Desktop\xyz\SampleReq.xml');
RemoveNamespace(XMLHTTPL.responseXML, XMLDomRequestL);
XMLDOMMgtG.SetNormalCase();
IF XMLDOMMgtG.FindNode(XMLDomRequestL, 'soap:Envelope/soap:Body/tns:create_service_request_status_response', XMLNodeL) THEN
BEGIN
XMLDOMMgtG.FindNodeTextEx(XMLNodeL,'CheckOpportunityResult/Header',100,StatusL);
XMLDOMMgtG.FindNodeTextEx(XMLNodeL,'value xsi:type="xsd:string">/Message',1024,MessageL);
XMLDOMMgtG.FindNodeTextEx(XMLNodeL,'CheckOpportunityResult/Message',100,MessageCodeL);
END;
IF XMLHTTPL.status <> 200 THEN
ERROR(STRSUBSTNO(XMLHelperG.GetHTTPErrorText(XMLHTTPL.status),XMLHTTPL.status));
// XMLDomRequestL.save('C:\Users\mehdis\Desktop\xyz\Sampleres.xml');
IF StatusL <> 'Success' THEN
ERROR(MessageL)
ELSE
MESSAGE(MessageL);
Answers
Can you give a shot with this
https://rockwithnav.wordpress.com/2016/02/23/consume-net-webservice-dotnet-data-type/
https://rockwithnav.wordpress.com/2016/02/23/consume-net-webservice-automation/
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/