I am in the process of trying to translate the following HTML code over to the Macro Scheduler HTTPRequest command. The code below basically takes an XML string that is entered in a html form text box (document.forms[0].requesterstr.value) and POSTS this command to a site that has a port/service name associated to it (http://site.com:9085/ServiceName). The response comes back to the form by writing the result (xmlHTTP.responseText) to the form (document.forms[0].resultstr.value). Below is the code behind my HTML form.
var xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
xmlHTTP.open("POST", "http://site.com:9085/ServiceName", false);
xmlHTTP.send(document.forms[0].requeststr.value);
document.forms[0].resultstr.value = xmlHTTP.responseText
I am trying to make this work using the HTTPRequest command, but it always returns with a status of 400. Below is the Macro scheduler script that I cannot get to work:
Let>TestXML=
HTTPRequest>http://site.com:9085/ServiceName,,POST, ... MLResponse
I am not sure if the HTTPRequest can handler the :9085/ServiceName. Also, am not sure if I go the VB route, I can't seem to use the "new ActiveXObject" syntax, since the VB interface only supports CreateObject syntax.
Is there something I am doing wrong with the HTTPRequest syntax that I need to do differently? I don't want to create a Macro Scheduler Script to poplate my HTML form and pull the responses from it if I can use the HTTPRequest or VB interface. Any help here would be appreciated.
HTTPRequest with ActiveXObject support
Moderators: JRL, Dorian (MJT support)
-
- Pro Scripter
- Posts: 51
- Joined: Tue Oct 03, 2006 4:22 pm
- Location: Akron, Ohio
- Contact:
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I just Searched and found this:
http://www.mjtnet.com/forum/viewtopic.php?t=1655
There's currently no way to override port 80 in HTTPRequest. Use the VBScript method as described above.
http://www.mjtnet.com/forum/viewtopic.php?t=1655
There's currently no way to override port 80 in HTTPRequest. Use the VBScript method as described above.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Pro Scripter
- Posts: 51
- Joined: Tue Oct 03, 2006 4:22 pm
- Location: Akron, Ohio
- Contact:
Thank you for the quick reply. I had been trying to use the VB solution you say with no luck, and then tried a few things with my "string" quotes, and it started working. Below is the code that works, where all I ended up doing is putting quotes around the %TestXML% string in the VB call. I originally had the quotes in the TextXML string, which was wrong.
VBSTART
Function HTTPPost(sUrl, sRequest)
set oHTTP = CreateObject("Microsoft.XMLHTTP")
oHTTP.open "POST", sUrl,false
oHTTP.setRequestHeader "Content-Type", "application/xml"
oHTTP.setRequestHeader "Content-Length", Len(sRequest)
oHTTP.send sRequest
If oHTTP.status=200 Then
HTTPPost = oHTTP.responseText
Else
HTTPPost = oHTTP.status
End If
End Function
VBEND
Let>TestXML=
VBEval>HTTPPost("http://website.com:9085/Service","%TestXML%"),HTMLResult
VBSTART
Function HTTPPost(sUrl, sRequest)
set oHTTP = CreateObject("Microsoft.XMLHTTP")
oHTTP.open "POST", sUrl,false
oHTTP.setRequestHeader "Content-Type", "application/xml"
oHTTP.setRequestHeader "Content-Length", Len(sRequest)
oHTTP.send sRequest
If oHTTP.status=200 Then
HTTPPost = oHTTP.responseText
Else
HTTPPost = oHTTP.status
End If
End Function
VBEND
Let>TestXML=
VBEval>HTTPPost("http://website.com:9085/Service","%TestXML%"),HTMLResult