Options

webSevics

artur+1artur+1 Member Posts: 18
edited 2014-11-19 in NAV Three Tier
Hi All,
I would like to ask one question:
Is it possible to send data to web service from Navision C/AL?
EX: I want to send parameters(Document No, Document Type) to web service after every posting of a document
in Navision 2013

Thanks in advance

Comments

  • Options
    thegunzothegunzo Member Posts: 274
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • Options
    massimopasqualimassimopasquali Member Posts: 82
    Hi,

    I have seen your example for webservice dotnet, but I didn't undestood where the codeunit should be installaed, on the NAV caller or on the NAV called?

    I have to call, from a Server NAV2013 A one codeunit on Server NAV2013 B.

    Actually I have doing this procedure on Server A, but don't work when the procedure called the codeunit on Server B
    ( WinHTTP.open('POST',ServiceURL,FALSE,Username,Password); ), the Server B or the service NAV on ( I suppose ) don't recognizes the Username e Password.

    Becouse you have had more experience, can you see my code, belove, and give me any suggestion?

    GetSetup;
    CREATE(XMLDoc,TRUE,TRUE);

    XMLProsInstr := XMLDoc.createProcessingInstruction('xml','version="1.0" encoding="utf-8"');
    XMLDoc.appendChild(XMLProsInstr);

    CreateEnvelope(XMLElement1);
    XMLElement2 := XMLDoc.createElement('soap:Body');
    XMLElement3 := XMLDoc.createElement('GetFarmerTankEntryAverageYW');
    XMLElement3.setAttribute('xmlns','urn:microsoft-dynamics-schemas/codeunit/RMWeb');
    CreateElement(XMLElement3, 'farmerID', FORMAT(FarmerID,0,9), '', '');
    CreateElement(XMLElement3, 'No', Nr, '', '');
    CreateElement(XMLElement3, 'tankEntryXML', '', '', '');
    XMLElement2.appendChild(XMLElement3);
    XMLElement1.appendChild(XMLElement2);
    XMLDoc.appendChild(XMLElement1);

    WinHTTP.open('POST',ServiceURL,FALSE,Username,Password);
    WinHTTP.setRequestHeader('Content-Type','text/xml; charset=utf-8');
    WinHTTP.setRequestHeader('SOAPAction','GetFarmerTankEntryAverageYW');
    WinHTTP.send(XMLDoc);

    IF WinHTTP.status <> 200 THEN
    ERROR(Text003,WinHTTP.status,WinHTTP.statusText);

    XMLResponseDoc.load(WinHTTP.responseXML);
    DisplayDocument(XMLResponseDoc);

    GetSetup()
    ServiceURL :='http://192.168.1.10:7107/DynNav71_VT7-TEST/WS/VT7-TEST/Codeunit/D01';
    // http://SV-IU-DEV.sv-iu.iperutility:7107 ... deunit/D01
    Username := '';
    Password := '';
    IF ISCLEAR(WinHTTP) THEN
    CREATE(WinHTTP,FALSE,TRUE);
    IF ISCLEAR(XMLResponseDoc) THEN
    CREATE(XMLResponseDoc,TRUE,FALSE);

    DisplayDocument(VAR XMLResponseDoc : Automation "'Microsoft XML, v6.0'.DOMDocument60")
    XMLBuffer.Read(XMLDoc);
    COMMIT;
    FORM.RUNMODAL(FORM::"XML Buffer");

    CreateEnvelope(VAR InElement : Automation "'Microsoft XML, v6.0'.IXMLDOMElement")
    InElement := XMLDoc.createElement('soap:Envelope');
    InElement.setAttribute('xmlns:soap','http://schemas.xmlsoap.org/soap/envelope/');
    InElement.setAttribute('xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance');
    InElement.setAttribute('xmlns:xsd','http://www.w3.org/2001/XMLSchema');

    CreateElement(VAR InElement : Automation "'Microsoft XML, v3.0'.IXMLDOMElement";InNodeName : Text[50];InNodeValue : Text[250];InAttribu
    TempElement := XMLDoc.createElement(InNodeName);
    TempElement.nodeTypedValue(InNodeValue);
    IF InAttributeName <> '' THEN
    TempElement.setAttribute(InAttributeName,InAttributeValue);
    InElement.appendChild(TempElement);
Sign In or Register to comment.