Options

Using DOMDocument in HTTP Request

AitorEGAitorEG Member Posts: 342
Hy everuone. I'm trying to send a generated XML file to a web service. I am quite new doing thios, so I am using as example the "Electronic VAT Information under SII" Addon. The problem is that in this Addon, it uses for processing XML files the DotNet type, while I have generated the XML like an automation, as you can see in the parameter passed to the procedure.
For DOMDocument type, it can be used the Encoding.UTF8.GetBytes(XMLDoc.OuterXml); method, so it doesn't work. I think I should change the way I create the HTTP Request, but i am quite lost. Any hint will be appreciate.

Thank you all


PROCEDURE InvokeSoapRequest@1000000000(XMLDoc@1100000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.DOMDocument";PackingNo@1000000000 : Code[20]);
    VAR
      WebRequest@1100009 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.WebRequest";
      HttpWebRequest@1100008 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.HttpWebRequest";
      RequestStream@1100005 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.Stream";
      Encoding@1100011 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Text.Encoding";
      ByteArray@1100012 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Array";
      Uri@1100006 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Uri";
      HttpWebResponse@1100010 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.HttpWebResponse";
      StatusCode@1100007 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.HttpStatusCode";
      WebServiceUrl@1100004 : Text;
      StatusDescription@1100017 : Text[250];
      ResponseText@1100015 : Text;
      lPackingHeader@1000000001 : Record 50010;
    BEGIN
      HttpWebRequest := WebRequest.Create(Uri.Uri('https://XXXXXXX/landing.html'));
      HttpWebRequest.Method := 'POST';
      HttpWebRequest.ContentType := 'application/xml';
      ByteArray := Encoding.UTF8.GetBytes(XMLDoc.OuterXml);   
      HttpWebRequest.ContentLength := ByteArray.Length; 
      RequestStream.Write(ByteArray,0,ByteArray.Length);  
      TryGetWebResponse(HttpWebRequest,HttpWebResponse);
      StatusCode := HttpWebResponse.StatusCode;
      StatusDescription := HttpWebResponse.StatusDescription;
      ResponseText := ReadHttpResponseAsText(HttpWebResponse);
      lPackingHeader.ProcessResponse(ResponseText,PackingNo);
    END;

Answers

  • Options
    AitorEGAitorEG Member Posts: 342
    No one has any clue? may be a format from DOMDOcument to XMLDocument in .NET... I am quite lost with this, I will probably have to change all the way of generatingthe XML and use an DotNet XML type....
  • Options
    ftorneroftornero Member Posts: 523
    If the problem is the Automation against the DotNet, you could save the XML and load agian, something like this:
    Name	DataType	Subtype	Length
    XMLDocDotNet	DotNet	System.Xml.XmlDocument.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'	
    
    XMLDoc.save(FileName);
    XMLDocDotNet.Load(FileName);
    
    

    And then use the XMLDocNet var in place of XMLDoc.

    Regards
  • Options
    AitorEGAitorEG Member Posts: 342
    edited 2017-10-31
    ftornero wrote: »
    If the problem is the Automation against the DotNet, you could save the XML and load agian, something like this:
    Name	DataType	Subtype	Length
    XMLDocDotNet	DotNet	System.Xml.XmlDocument.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'	
    
    XMLDoc.save(FileName);
    XMLDocDotNet.Load(FileName);
    
    

    And then use the XMLDocNet var in place of XMLDoc.

    Regards

    Yes, really thanks! That is what I was specting, but I couldn't find it! What type should "filename" be? A string? What does it represent?

    Really appreciate!
  • Options
    ftorneroftornero Member Posts: 523
    File Name is a string and the path and name of a file where you save the XML and then you load the saved XML to the XMLDocDotNet var.
  • Options
    AitorEGAitorEG Member Posts: 342
    ftornero wrote: »
    File Name is a string and the path and name of a file where you save the XML and then you load the saved XML to the XMLDocDotNet var.

    Again, thank you very much. i was getting mad with this issue, and the worst thng is that I was thinking about it, but dindn't find the way. I will work on this solution

    Really appreciated!
Sign In or Register to comment.