Reading large txt from WinHttp.ResponseText Property

jelittlejohnjelittlejohn Member Posts: 61
Hi,

I am using the WinHttp Automation Server to send credit card processing info to a processor for authorization, etc. I just began testing today and all was looking good from a Navision standpoint. I was able to read the response to a Text variable 0f length 1024. However, my response was basically header info with blank for the data except for an error message as I was sending incorrect login info. Once I got my login info corrected, I tried again but my code blew up as soon as I tried to read the full(complete response info) WinHttp.Responsetext into my text variable saying that I had exceeded the length of the string buffer. I then tried everything else I could thing of :BigText, BLOB, files all with INSTREAM but had no success with anything. I have searched the forum extensively and admit that the results were not encouraging. However, I wanted to ask once more before I began searching for alternative methods whether that involves writing my own automation object or whatever. Can anyone help with this problem?

Thanks in advance,
Jack
Jack Littlejohn
Clemson, SC

Answers

  • ara3nara3n Member Posts: 9,256
    I suggest to use MSXML 6.0 instead of winhttp. more specifically xmlhttpserver

    The buffer error is a limitation of NAV interface to automation.

    You need to use Stream instead. Do not use Responsetext function but Response.

    Is the response an xml file?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • jelittlejohnjelittlejohn Member Posts: 61
    Had no luck using MSXML 6.0 instead of WinHttp as my send statement return an error.

    I did continue to try streaming both WinHttp.ResponseString and WinHttp.ResponseBody into a BLOB field with the following code:


    CCJnl.Response.CREATEINSTREAM(instr);
    int := instr.READ(WinHttp.ResponseStream);

    However the response stream threw the following error:

    "You are using an invalid data type for this function"

    I have some limited experience with INSTREAM and OUTSTREAM but none with WinHttp until this effort. Am I making an obvious stupid mistake?

    Thanks,
    Jack
    Jack Littlejohn
    Clemson, SC
  • jreynoldsjreynolds Member Posts: 175
    How about using the ResponseStream method to create an InStream and then read this into a BigText variable:
    InStr := WinHTTP.ResponseStream;
    BigTxt.READ(Instr);
    
  • jelittlejohnjelittlejohn Member Posts: 61
    Thank You! I was able to read the responsestream into a BigText variable using this method. =D> I had thought I was going to have to try to create a custom automation object for awhile there but was trying desperately to avoid that so I wouldn't have to install it on all client machines. I was able to write the bigtext variable to a file for viewing so now I'm back to figuring out what the codes I received back mean. Thanks again!!
    Jack Littlejohn
    Clemson, SC
  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from 'NAV 2009' forum to 'NAV/Navision' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • alwaysgunaalwaysguna Member Posts: 45
    Hi

    I am facing a similar situation where I am trying to read the data from WinHttp.GetAllResponseHeaders() and would like to store it as a file. This function doesnt allow the response to be streamed nor could be assigned to bigtext.

    Any possible workarounds ?
    Guna
  • SogSog Member Posts: 1,023
    iterate over the responseheaders and use the winhttp.responsestream to append the bigtext?
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • alwaysgunaalwaysguna Member Posts: 45
    Hi Sog
    How do I iterate over the responseheaders ? Do you mean using GetResponseheader()

    I am facing the below issue when I do that

    http://www.autoitscript.com/forum/topic/80855-help-with-winhttpwinhttprequest-object/
    Guna
Sign In or Register to comment.