West Wind Internet and Client Tools
AddPostKey() help
Gravatar is a globally recognized avatar based on your email address. AddPostKey() help
  Naeem Afzal
  All
  Jun 17, 2015 @ 03:13am
Hi,

I am using the following test code to get some value from my local web server script to VFP client.

===============
Client Side code is
===============

LOCAL lcCode

lcCode = "ABCD"

loHTTP = CREATEOBJECT("wwHTTP")

*** Posting Form Variables
loHTTP.nHttpPostMode = 1

loHTTP.cHttpVerb = "GET" && Also tried it with POST.

loHTTP.AddPostKey()

loHTTP.AddPostKey("code",lcCode)

IF loHTTP.nError <> 0
? loHTTP.nError
set step on
ENDIF

? lcStr

RETURN

This code return no error but complete web page is not returned. I only get this

<Html>
<body>
</body>
</Html>

if I run the above code without Addpostkey() as

lcStr = loHTTP.HttpGet("server-ip/script.wws?lcCode=ABCD")

I get the complete result from my web server.

What am I doing wrong with AddPostKey() version ?


The server code "script.wws" is
=============================

<Html>
<body>
<%
local lcCode
lcCode = ''

lcCode=IIF(ISNULL(Request.Querystring("code")),'',Request.Querystring("code"))

if type('lcCode') <> 'C'
lcCode = ''
endif

lcCode = allt(lcCode)

lcRetStr = ""

if !empty(lcCode)

SELECT * ;
FROM table1 ;
where alltrim(code) == lcCode ;
INTO CURSOR tCursor

select tCursor
=CURSORTOXML(0,'lcRetStr',1,1+2,0,'1')

use in sele('tCursor')

use in sele('table1')

endif

%>
<%=lcRetStr%>

</body>

</Html>


Gravatar is a globally recognized avatar based on your email address. Re: AddPostKey() help
  FoxInCloud Support - Thierry N.
  Naeem Afzal
  Jun 17, 2015 @ 03:55am
client
o = newobject('wwHTTP', 'wwHTTP.prg')
o.addPostKey('key', transform(value))
result = o.HTTPget(URL)

server

value = cast(evl(m.request.form('key'), m.request.queryString('key')) as ...)

select ... where key = m.value

etc.


Hi,

I am using the following test code to get some value from my local web server script to VFP client.

===============
Client Side code is
===============

LOCAL lcCode

lcCode = "ABCD"

loHTTP = CREATEOBJECT("wwHTTP")

*** Posting Form Variables
loHTTP.nHttpPostMode = 1

loHTTP.cHttpVerb = "GET" && Also tried it with POST.

loHTTP.AddPostKey()

loHTTP.AddPostKey("code",lcCode)

IF loHTTP.nError <> 0
? loHTTP.nError
set step on
ENDIF

? lcStr

RETURN

This code return no error but complete web page is not returned. I only get this

<Html>
<body>
</body>
</Html>

if I run the above code without Addpostkey() as

lcStr = loHTTP.HttpGet("server-ip/script.wws?lcCode=ABCD")

I get the complete result from my web server.

What am I doing wrong with AddPostKey() version ?


The server code "script.wws" is
=============================

<Html>
<body>
<%
local lcCode
lcCode = ''

lcCode=IIF(ISNULL(Request.Querystring("code")),'',Request.Querystring("code"))

if type('lcCode') <> 'C'
lcCode = ''
endif

lcCode = allt(lcCode)

lcRetStr = ""

if !empty(lcCode)

SELECT * ;
FROM table1 ;
where alltrim(code) == lcCode ;
INTO CURSOR tCursor

select tCursor
=CURSORTOXML(0,'lcRetStr',1,1+2,0,'1')

use in sele('tCursor')

use in sele('table1')

endif

%>
<%=lcRetStr%>

</body>

</Html>

Gravatar is a globally recognized avatar based on your email address. Re: AddPostKey() help
  Rick Strahl
  Naeem Afzal
  Jun 17, 2015 @ 08:15am
Guessing the result is null and no data is returned - hence an empty result. You also need to set the content type if you are returning XML.

If you are planning to return XML using a template is not a good way to do it unless there's only code in the template. Even if your code was working you'd get HTML wrapped inside of an HTML header which would be invalid XML.

Using a process method is better for this sort of thing. If you're displaying the initial data call Response.ExpandScript() to display the HTML. When you're posting the data back render the XML then return the raw XML response:

Response.ContentType = "text/xml"
Response.Write(lcXml)

+++ Rick ---


Hi,

I am using the following test code to get some value from my local web server script to VFP client.

===============
Client Side code is
===============

LOCAL lcCode

lcCode = "ABCD"

loHTTP = CREATEOBJECT("wwHTTP")

*** Posting Form Variables
loHTTP.nHttpPostMode = 1

loHTTP.cHttpVerb = "GET" && Also tried it with POST.

loHTTP.AddPostKey()

loHTTP.AddPostKey("code",lcCode)

IF loHTTP.nError <> 0
? loHTTP.nError
set step on
ENDIF

? lcStr

RETURN

This code return no error but complete web page is not returned. I only get this

<Html>
<body>
</body>
</Html>

if I run the above code without Addpostkey() as

lcStr = loHTTP.HttpGet("server-ip/script.wws?lcCode=ABCD")

I get the complete result from my web server.

What am I doing wrong with AddPostKey() version ?


The server code "script.wws" is
=============================

<Html>
<body>
<%
local lcCode
lcCode = ''

lcCode=IIF(ISNULL(Request.Querystring("code")),'',Request.Querystring("code"))

if type('lcCode') <> 'C'
lcCode = ''
endif

lcCode = allt(lcCode)

lcRetStr = ""

if !empty(lcCode)

SELECT * ;
FROM table1 ;
where alltrim(code) == lcCode ;
INTO CURSOR tCursor

select tCursor
=CURSORTOXML(0,'lcRetStr',1,1+2,0,'1')

use in sele('tCursor')

use in sele('table1')

endif

%>
<%=lcRetStr%>

</body>

</Html>


Rick Strahl
West Wind Technologies

Making waves on the Web
from Hood River

Gravatar is a globally recognized avatar based on your email address. Re: AddPostKey() help
  Naeem Afzal
  Thierry Nivelet (FoxInCloud)
  Jun 28, 2015 @ 04:50am
Thank you Thierry.

© 1996-2024