How to do a post using the navigate method of web browser control?

I am trying to open a URL using webbrowser control by doing a HTTP POST with some xml data to the URL (instead of HTTP GET it normally does). However my code is not working:

DEF VAR wkTarget AS CHAR NO-UNDO.
DEF VAR wkpostData AS INT NO-UNDO.

create "InternetExplorer.Application" chExplorer.
Assign
chExplorer:menubar = false
chExplorer:addressbar = false
chExplorer:toolbar = false no-error.

assign
wkurl = "http://localhost/scripts/cgiip.exe/WService=wsbroker/web/testxml.p"
wkFlags = 0
wkTarget = ""
wkPostData = "somevalue
wkHeaders = "Content-Type: text/xml" +
Chr(10) + Chr(13) +
"Content-Length: " + STRING(LENGTH(wkPostData)) + Chr(10) + Chr(13) +
Chr(10) + Chr(13).

chExplorer:visible = TRUE.
chExplorer:Navigate (wk-url, wkFlags, wkTarget, wkPostData, wkHeaders).

On further enquiry in MSDN I have found that 4th parameter of the nagigate method has to be a SAFEARRAY structure stored in a variable of data type variant. How does one do the same in progress. I tried the following but it is not working either:

DEF VAR mXmlData AS MEMPTR NO-UNDO.
DEF VAR mSafeArray AS MEMPTR NO-UNDO.

ip-Size = LENGTH(wkPostdata).
SET-SIZE(mXmlData) = ip-Size.
PUT-STRING(mXmlData,1) = wkPostData.

SET-SIZE(mSafeArray) = 2 /* WORD cDims */
+ 2 /* WORD fFeatures */
+ 4 /* DWORD cbElements */
+ 4 /* DWORD cLocks */
+ 4 /* void * pvData */
+ 4 /* SAFEARRAYBOUND rgsabound[1] - DWORD cElements */
+ 4 /* SAFEARRAYBOUND rgsabound[1] - LONG lLbound */
.

PUT-SHORT(mSafeArray,1) = 1.
PUT-SHORT(mSafeArray,3) = 0.
PUT-LONG(mSafeArray,5) = 1.
PUT-LONG(mSafeArray,9) = 0.
PUT-LONG(mSafeArray,13) = GET-POINTER-VALUE(mXmlData).
PUT-LONG(mSafeArray,17) = ip-Size.
PUT-LONG(mSafeArray,21) = 0.

ASSIGN
wkFlags = 0
wkTarget = ""
wkPostData = GET-POINTER-VALUE(mSafeArray)
wkHeaders = "Content-Type: text/xml" +
Chr(10) + Chr(13) +
"Content-Length: " + STRING(ip-Size) +
Chr(10) + Chr(13) +
Chr(10) + Chr(13).


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

im presented with this exact

im presented with this exact same problem at the moment i need to do a http POST from within a procedure.

did you ever get a resolution to this issue?


in the end i found a way

in the end i found a way around this.
not the most elegant solution but the end user shouldnt see any difference

basically you create the form post in your code on the fly it worked for my implementation but you may have different requirements

heres an example.

CREATE "InternetExplorer.Application" vchInternetExplorer NO-ERROR.
IF ERROR-STATUS:ERROR THEN DO:
RUN pr-error("Intenet Explorer Not Installed").
RETURN.
END.

vchInternetExplorer:Navigate("about:blank").
vchInternetExplorer:Document:body:innerHTML = " BUILD YOUR FORM IN HMTML HERE.".

vchInternetExplorer:Document:frm1:submit().
ASSIGN vchInternetExplorer:VISIBLE = TRUE.

RELEASE OBJECT vchInternetExplorer.