How Send XML Document via HTTP Post Using DotNet?

Hi to all,

I'd like to know how you can send an XML file via HTTP POST using DotNET.

I'm currently using the seguende code:
http://forum.mibuso.com/discussion/comment/296881/#Comment_296881

In the case:
URL[1] :=                     '\\****************\************\ICT\JSS\EDI\Invoice200117.xml';
WebaddressToPostTo    :=      'http://IP:PORT/http?request=send';

..but I get an error:
"The system can not locate the resource"

Can you help me? Thanks in advance.

MGRS

Best Answers

Answers

  • zohaibu95@hotmail.comzohaibu95@hotmail.com Member Posts: 223
    edited 2017-01-20
    I have wrote this code in NAV 2009 but you can replace Automation with DotNet type. The logic will remains the same.

    Variables are as under:

    ul9ryqxly8et.png



    Code:
    CLEAR(TempBlob);
    TempBlob.Blob.CREATEOUTSTREAM(OS);
    Customer.GET('30000');
    
    //Set the view for the XMLPort
     CustomerXML.SETTABLEVIEW(Customer);
     
    // Use the TempBlob record to get a blob stream
    TempBlob.Blob.CREATEOUTSTREAM(OS);
    CustomerXML.SETDESTINATION(OS);
    // export the contents of the XMLPort to a blob
    CustomerXML.EXPORT;
     
    TempBlob.CALCFIELDS(Blob);
    TempBlob.Blob.CREATEINSTREAM(IS);
    
    
    IF ISCLEAR(XMLHTTP) THEN //'Microsoft XML, v6.0'.XMLHTTP60
      CREATE(XMLHTTP);
    IF ISCLEAR(XMLDoc) THEN //'Microsoft XML, v6.0'.DOMDocument
      CREATE(XMLDoc);
    
    XMLDoc.load(IS);
    
    XMLHTTP.open('POST', WebAddress, FALSE);
    XMLHTTP.setRequestHeader('Content-Type', 'text/xml');
    XMLHTTP.send(XMLDoc);
    
    IF XMLHTTP.status = 200 THEN BEGIN
      IF (XMLHTTP.responseText <> '') THEN BEGIN
    
      END;
    END ELSE BEGIN
      ERROR('Status %1 %2',XMLHTTP.status,XMLHTTP.statusText);
    END;
    
    CLEAR(XMLDoc);
    CLEAR(XMLHTTP);
    
    Best Regards
    Zohaib Ahmed
    Dynamics NAV ERP Technical Consultant.

    please like / agree / verify my answer, if it was helpful for you. thanks.
  • michelegrsmichelegrs Member Posts: 3
    Hi zohaibu,

    many thanks for the swift answer, unfortunately I'm forced to use dotnet.


    MicheleGRS
  • zohaibu95@hotmail.comzohaibu95@hotmail.com Member Posts: 223
    @michelegrs just replace Automation with DotNet rest will be the same :)
    Best Regards
    Zohaib Ahmed
    Dynamics NAV ERP Technical Consultant.

    please like / agree / verify my answer, if it was helpful for you. thanks.
  • zohaibu95@hotmail.comzohaibu95@hotmail.com Member Posts: 223
    michelegrs wrote: »
    Many thanks to all,

    you've been really very kind. I solved.

    umy8f8837o7g.png

    You are welcome :)
    Best Regards
    Zohaib Ahmed
    Dynamics NAV ERP Technical Consultant.

    please like / agree / verify my answer, if it was helpful for you. thanks.
  • sooniorysooniory Member Posts: 2
    @michelegrs could you give the dotnet reference of HTTPRequest Var? Thanks!
Sign In or Register to comment.