Discussion:
VBScript HTTP XML Post - Please help!
(too old to reply)
Anthony Ford
2004-02-18 18:13:29 UTC
Permalink
Anyone who can help will earn MANY gold stars in heaven, karma, whatever.

Here's what I need to accomplish and I need to do it in a very short time,
so some very basic sample code is really what I need.

1 - Receive an XML post via HTTPS - The system posting will be a Java
servlet. Can I listen for the post with an ASP page in a "browser-less"
transaction? My goal here is to receive the XML and dump the data into SQL
Server. I'm very familiar with how to create / open / execute / close db
connections with VBScript, but I thought I'd tell you what I'm doing with
the data once I get it. Also, I'm using IIS 5 and SQL Server 2000.

2 - Send an XML post again via HTTPS - This process will be an automated
process (overnight), so I need to accomplish this with a .VBS file, not an
ASP page.

I've searched and searched for this but all I keep coming up with is .NET
information. I really don't have time to learn how to use .NET and create
components and the like. Plus, I like to keep things sort of light-weight
and easy ... even if it is old-fashioned.

Thank you so much for any help!
Anthony
Ray at <%=sLocation%> [MVP]
2004-02-18 18:27:49 UTC
Permalink
Try this.

Function GetPostResponse()
Dim oXML, sURL
Dim sContents
sURL = "https://domain/page.asp"
Set oXML = CreateObject("MSXML2.ServerXMLHTTP")
oXML.Open "POST", sURL, False
oXML.SetRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
oXML.Send "txtUsername=Anthony&txtPassword=abcdefghi"
GetPostResponse = oXML.responseText
Set oXML = Nothing
End Sub

Ray at work
Post by Anthony Ford
Anyone who can help will earn MANY gold stars in heaven, karma, whatever.
Here's what I need to accomplish and I need to do it in a very short time,
so some very basic sample code is really what I need.
1 - Receive an XML post via HTTPS - The system posting will be a Java
servlet. Can I listen for the post with an ASP page in a "browser-less"
transaction? My goal here is to receive the XML and dump the data into SQL
Server. I'm very familiar with how to create / open / execute / close db
connections with VBScript, but I thought I'd tell you what I'm doing with
the data once I get it. Also, I'm using IIS 5 and SQL Server 2000.
2 - Send an XML post again via HTTPS - This process will be an automated
process (overnight), so I need to accomplish this with a .VBS file, not an
ASP page.
I've searched and searched for this but all I keep coming up with is .NET
information. I really don't have time to learn how to use .NET and create
components and the like. Plus, I like to keep things sort of light-weight
and easy ... even if it is old-fashioned.
Thank you so much for any help!
Anthony
Ray at <%=sLocation%> [MVP]
2004-02-18 18:34:53 UTC
Permalink
Make that End Function at the end...

Ray at work

"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
Post by Ray at <%=sLocation%> [MVP]
Try this.
Function GetPostResponse()
Dim oXML, sURL
Dim sContents
sURL = "https://domain/page.asp"
Set oXML = CreateObject("MSXML2.ServerXMLHTTP")
oXML.Open "POST", sURL, False
oXML.SetRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
oXML.Send "txtUsername=Anthony&txtPassword=abcdefghi"
GetPostResponse = oXML.responseText
Set oXML = Nothing
End Sub
Ray at work
Post by Anthony Ford
Anyone who can help will earn MANY gold stars in heaven, karma, whatever.
Here's what I need to accomplish and I need to do it in a very short time,
so some very basic sample code is really what I need.
1 - Receive an XML post via HTTPS - The system posting will be a Java
servlet. Can I listen for the post with an ASP page in a "browser-less"
transaction? My goal here is to receive the XML and dump the data into
SQL
Post by Anthony Ford
Server. I'm very familiar with how to create / open / execute / close db
connections with VBScript, but I thought I'd tell you what I'm doing with
the data once I get it. Also, I'm using IIS 5 and SQL Server 2000.
2 - Send an XML post again via HTTPS - This process will be an automated
process (overnight), so I need to accomplish this with a .VBS file, not an
ASP page.
I've searched and searched for this but all I keep coming up with is .NET
information. I really don't have time to learn how to use .NET and create
components and the like. Plus, I like to keep things sort of light-weight
and easy ... even if it is old-fashioned.
Thank you so much for any help!
Anthony
Anthony Ford
2004-02-18 18:42:18 UTC
Permalink
Shooting for those gold stars I see. :-) Thanks for the quickness.

If I'm not mistaken, this routine looks like a post, which I'm eager to try.
But I need my listener so I can bounce messages back and forth before I go
to the other guy and say I'm ready to test connectivity.

Thanks again!

Anthony


"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
Post by Ray at <%=sLocation%> [MVP]
Make that End Function at the end...
Ray at work
"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
Post by Ray at <%=sLocation%> [MVP]
Try this.
Function GetPostResponse()
Dim oXML, sURL
Dim sContents
sURL = "https://domain/page.asp"
Set oXML = CreateObject("MSXML2.ServerXMLHTTP")
oXML.Open "POST", sURL, False
oXML.SetRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
oXML.Send "txtUsername=Anthony&txtPassword=abcdefghi"
GetPostResponse = oXML.responseText
Set oXML = Nothing
End Sub
Ray at work
Post by Anthony Ford
Anyone who can help will earn MANY gold stars in heaven, karma,
whatever.
Post by Ray at <%=sLocation%> [MVP]
Post by Anthony Ford
Here's what I need to accomplish and I need to do it in a very short
time,
Post by Ray at <%=sLocation%> [MVP]
Post by Anthony Ford
so some very basic sample code is really what I need.
1 - Receive an XML post via HTTPS - The system posting will be a Java
servlet. Can I listen for the post with an ASP page in a
"browser-less"
Post by Ray at <%=sLocation%> [MVP]
Post by Ray at <%=sLocation%> [MVP]
Post by Anthony Ford
transaction? My goal here is to receive the XML and dump the data into
SQL
Post by Anthony Ford
Server. I'm very familiar with how to create / open / execute / close
db
Post by Ray at <%=sLocation%> [MVP]
Post by Anthony Ford
connections with VBScript, but I thought I'd tell you what I'm doing
with
Post by Ray at <%=sLocation%> [MVP]
Post by Anthony Ford
the data once I get it. Also, I'm using IIS 5 and SQL Server 2000.
2 - Send an XML post again via HTTPS - This process will be an automated
process (overnight), so I need to accomplish this with a .VBS file,
not
Post by Ray at <%=sLocation%> [MVP]
an
Post by Ray at <%=sLocation%> [MVP]
Post by Anthony Ford
ASP page.
I've searched and searched for this but all I keep coming up with is
.NET
Post by Ray at <%=sLocation%> [MVP]
Post by Anthony Ford
information. I really don't have time to learn how to use .NET and
create
Post by Ray at <%=sLocation%> [MVP]
Post by Anthony Ford
components and the like. Plus, I like to keep things sort of
light-weight
Post by Ray at <%=sLocation%> [MVP]
Post by Anthony Ford
and easy ... even if it is old-fashioned.
Thank you so much for any help!
Anthony
Ray at <%=sLocation%> [MVP]
2004-02-18 18:45:35 UTC
Permalink
Post by Anthony Ford
Shooting for those gold stars I see. :-) Thanks for the quickness.
I prefer silver stars! :]
Post by Anthony Ford
If I'm not mistaken, this routine looks like a post, which I'm eager to try.
But I need my listener so I can bounce messages back and forth before I go
to the other guy and say I'm ready to test connectivity.
I don't understand what that means. If that's a query for additionaly info
or code, can you rephrase it? If not, ignore this reply.

Ray at work
Anthony Ford
2004-02-18 18:58:44 UTC
Permalink
Sorry for my vagueness.

I'd like to set up my own test environment by sending AND receiving XML
between two of my own servers. The code you sent looks like an answer to
the 2nd part of my original message - the ability to post XML to someone
else via VBScript.

Does your code also function as "listener" or do I need something else for
that?

Anthony


"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
Post by Ray at <%=sLocation%> [MVP]
Post by Anthony Ford
Shooting for those gold stars I see. :-) Thanks for the quickness.
I prefer silver stars! :]
Post by Anthony Ford
If I'm not mistaken, this routine looks like a post, which I'm eager to
try.
Post by Anthony Ford
But I need my listener so I can bounce messages back and forth before I go
to the other guy and say I'm ready to test connectivity.
I don't understand what that means. If that's a query for additionaly info
or code, can you rephrase it? If not, ignore this reply.
Ray at work
Ray at <%=sLocation%> [MVP]
2004-02-18 19:17:31 UTC
Permalink
What's a listener? Do you just want to do normal GET requests as well?

Function GetGetResponse()
Dim oXML, sURL
Dim sContents
sURL = "https://domain/page.asp"
Set oXML = CreateObject("MSXML2.ServerXMLHTTP")
oXML.Open "GET", sURL, False
oXML.Send ""
GetGetResponse = oXML.responseText
Set oXML = Nothing
End Sub

Ray at work
Post by Anthony Ford
Sorry for my vagueness.
I'd like to set up my own test environment by sending AND receiving XML
between two of my own servers. The code you sent looks like an answer to
the 2nd part of my original message - the ability to post XML to someone
else via VBScript.
Does your code also function as "listener" or do I need something else for
that?
Anthony
"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
Post by Ray at <%=sLocation%> [MVP]
Post by Anthony Ford
Shooting for those gold stars I see. :-) Thanks for the quickness.
I prefer silver stars! :]
Post by Anthony Ford
If I'm not mistaken, this routine looks like a post, which I'm eager to
try.
Post by Anthony Ford
But I need my listener so I can bounce messages back and forth before
I
Post by Anthony Ford
go
Post by Ray at <%=sLocation%> [MVP]
Post by Anthony Ford
to the other guy and say I'm ready to test connectivity.
I don't understand what that means. If that's a query for additionaly
info
Post by Ray at <%=sLocation%> [MVP]
or code, can you rephrase it? If not, ignore this reply.
Ray at work
Anthony Ford
2004-02-18 19:56:09 UTC
Permalink
Post by Ray at <%=sLocation%> [MVP]
What's a listener? Do you just want to do normal GET requests as well?
Nope. The POST code you sent me looks like the right thing for sending the
xml stream TO someone else. I need to have a page (ASP?) sitting on my
server available for someone else to send ME an xml stream.

Here's a diagram of what's happening:

myCode.vbs -------XML------> https://someurl/someserverpage.xyz
someServlet.java -----XML----> https://myurl/myPage.asp


It looks like the code you gave me goes in "myCode.vbs" but what is the code
that I need to have in "myPage.asp" that's ready to receive xml? I need to
know how to code "myPage.asp" so that when someone sends me xml, I have the
page in place to receive it.

Or am I missing something? Does the code you send me do sending AND
receiving?

Anthony
Ray at <%=sLocation%> [MVP]
2004-02-18 20:03:38 UTC
Permalink
Okay, in this case, then you'd want to setup an ASP page (assuming you have
a Windows server).

myPage.asp doesn't have to be ready to receive anything, aside from its
being hosted on an IIS server and having ASP code. Have you ever created an
ASP page?

Ray at work
Post by Anthony Ford
Post by Ray at <%=sLocation%> [MVP]
What's a listener? Do you just want to do normal GET requests as well?
Nope. The POST code you sent me looks like the right thing for sending the
xml stream TO someone else. I need to have a page (ASP?) sitting on my
server available for someone else to send ME an xml stream.
myCode.vbs -------XML------> https://someurl/someserverpage.xyz
someServlet.java -----XML----> https://myurl/myPage.asp
It looks like the code you gave me goes in "myCode.vbs" but what is the code
that I need to have in "myPage.asp" that's ready to receive xml? I need to
know how to code "myPage.asp" so that when someone sends me xml, I have the
page in place to receive it.
Or am I missing something? Does the code you send me do sending AND
receiving?
Anthony
Anthony Ford
2004-02-18 20:20:39 UTC
Permalink
Post by Ray at <%=sLocation%> [MVP]
myPage.asp doesn't have to be ready to receive anything, aside from its
being hosted on an IIS server and having ASP code. Have you ever created an
ASP page?
Yep, I'm using IIS 5 and yes, I'm quite familiar with ASP, I've just never
used XML.

When I say "ready to receive", I guess I'm speaking in the sense that if a
form on a web page has ...

<form action="handlerPage.asp" method="post>

... I consider handlerPage.asp to be "ready to receive" a post from said
form.


Anthony
Anthony Ford
2004-02-18 20:23:25 UTC
Permalink
Oh, and I don't know if it makes any difference, but keep in mind that
myPage.asp will be hit by what I mentioned before as a "browser-less"
process. That is, someone is going to initiate the stream with a Java
servlet in the wee hours of the morning, not in a browser.


"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
Post by Ray at <%=sLocation%> [MVP]
Okay, in this case, then you'd want to setup an ASP page (assuming you have
a Windows server).
myPage.asp doesn't have to be ready to receive anything, aside from its
being hosted on an IIS server and having ASP code. Have you ever created an
ASP page?
Ray at work
Post by Anthony Ford
Post by Ray at <%=sLocation%> [MVP]
What's a listener? Do you just want to do normal GET requests as well?
Nope. The POST code you sent me looks like the right thing for sending
the
Post by Anthony Ford
xml stream TO someone else. I need to have a page (ASP?) sitting on my
server available for someone else to send ME an xml stream.
myCode.vbs -------XML------> https://someurl/someserverpage.xyz
someServlet.java -----XML----> https://myurl/myPage.asp
It looks like the code you gave me goes in "myCode.vbs" but what is the
code
Post by Anthony Ford
that I need to have in "myPage.asp" that's ready to receive xml? I need
to
Post by Anthony Ford
know how to code "myPage.asp" so that when someone sends me xml, I have
the
Post by Anthony Ford
page in place to receive it.
Or am I missing something? Does the code you send me do sending AND
receiving?
Anthony
Ray at <%=sLocation%> [MVP]
2004-02-18 20:29:04 UTC
Permalink
Post by Anthony Ford
Oh, and I don't know if it makes any difference, but keep in mind that
myPage.asp will be hit by what I mentioned before as a "browser-less"
process. That is, someone is going to initiate the stream with a Java
servlet in the wee hours of the morning, not in a browser.
That's fine as long as it's sending http requests that are normal. Think
about the code that I first posted. If the url was
http://someoneelse'ssite/someoneelse'spage.asp, that person didn't have to
do anything special in order for you to be able to post data to it this way.
You don't have to do anything special in your page either.

Ray at work
Anthony Ford
2004-02-18 20:49:31 UTC
Permalink
Cool. I'll monkey around with it and check back in tomorrow. I really
appreciate your time and help.

Anthony


"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
Post by Ray at <%=sLocation%> [MVP]
Post by Anthony Ford
Oh, and I don't know if it makes any difference, but keep in mind that
myPage.asp will be hit by what I mentioned before as a "browser-less"
process. That is, someone is going to initiate the stream with a Java
servlet in the wee hours of the morning, not in a browser.
That's fine as long as it's sending http requests that are normal. Think
about the code that I first posted. If the url was
http://someoneelse'ssite/someoneelse'spage.asp, that person didn't have to
do anything special in order for you to be able to post data to it this way.
You don't have to do anything special in your page either.
Ray at work
Han
2004-02-19 05:05:20 UTC
Permalink
Hi Anthony

If your problem is not yet solved...

Let me start from posting again. Posting XML is very simple.

xmldom.loadxml "<x/>"
xmlhttp.open url, "post", false
xmlhttp.send xmldom
msgbox xmlhttp.responseXml.xml

That's all except createObject part. Not pseudo code. Now your ASP may be

xmldom.load request
xmldom.documentelement.text = "hello"
response.contentType="text/xml"
xmldom.save request

That's all except createObject part. The ASP received/send from/to the
caller. Now you should see something like this at the caller part.
<x>hello</x>.
--
Pohwan Han, Microsoft MVP, ASP/ASP.Net, Korea
Have a nice day.
Post by Anthony Ford
Cool. I'll monkey around with it and check back in tomorrow. I really
appreciate your time and help.
Anthony
"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
Post by Ray at <%=sLocation%> [MVP]
Post by Anthony Ford
Oh, and I don't know if it makes any difference, but keep in mind that
myPage.asp will be hit by what I mentioned before as a "browser-less"
process. That is, someone is going to initiate the stream with a Java
servlet in the wee hours of the morning, not in a browser.
That's fine as long as it's sending http requests that are normal.
Think
Post by Anthony Ford
Post by Ray at <%=sLocation%> [MVP]
about the code that I first posted. If the url was
http://someoneelse'ssite/someoneelse'spage.asp, that person didn't have to
do anything special in order for you to be able to post data to it this
way.
Post by Ray at <%=sLocation%> [MVP]
You don't have to do anything special in your page either.
Ray at work
Michael Harris (MVP)
2004-02-19 03:48:17 UTC
Permalink
Post by Anthony Ford
myCode.vbs -------XML------> https://someurl/someserverpage.xyz
someServlet.java -----XML----> https://myurl/myPage.asp
The ASP page would create an msxml2.domdocument and pass the Request object
to the Load method...

Google Search: domdocument load request xml group:microsoft.* author:Michael
Harris
http://groups.google.com/groups?q=domdocument%20load%20request%20xml%20%20group:microsoft.*%20author:Michael%20Harris&num=100&scoring=d

Google Search: domdocument load request xml site:msdn.microsoft.com
http://www.google.com/search?q=domdocument%20load%20request%20xml%20%20site:msdn.microsoft.com&num=100&scoring=d
--
Michael Harris
Microsoft.MVP.Scripting

Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp

TechNet Script Center Sample Scripts
http://www.microsoft.com/technet/scriptcenter/default.asp
Download in HTML Help format (searchable)
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942

WSH 5.6 documentation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en
Loading...