This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Microsoft XML > March 2005 > Posting XML File
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| I am attempting to post an XML file to a HTTPS .... .jsp url with a vbscript.
Can someone help?
| |
| Joe Fawcett 2005-03-25, 6:34 pm |
| "David" <David@discussions.microsoft.com> wrote in message
news:28E43411-41B6-4FE6-B393-0548806A5AA7@microsoft.com...
>I am attempting to post an XML file to a HTTPS .... .jsp url with a vbscript.
>
> Can someone help?
I have this for doing that in jscript. If you can't translate let me know:
function doHttpPost(From, To, Data)
{
var oXmlHttp = new ActiveXObject("Msxml2.XmlHttp.4.0"); //Change to version 3 if
necessary
oXmlHttp.open("POST", From, false);
oXmlHttp.send(Data);
if (oXmlHttp.status == 200)
{
var oStream = new ActiveXObject("Adodb.Stream");
oStream.type = 1; //Binary
oStream.open();
oStream.write(oXmlHttp.responseBody);
oStream.saveToFile(To, 2); //Create if needed and overwrite if necessary
oStream.close();
}
else
{
throw new Error(oXmlHttp.statusText); //Needs improving
}
}
//Example
var sXml = "<data><element/></data>";
doHttpPost(<url to web page goes here, <results saved here>, sXml);
| |
| Martin Honnen 2005-03-25, 6:34 pm |
|
David wrote:
> I am attempting to post an XML file to a HTTPS .... .jsp url with a vbscript.
Pseudo code for VBScript Windows Script host file:
Dim HttpRequest, PostUrl, XmlDocument, Loaded, FileName
PostUrl = "https://example.com/2005/03/xmlupload.jsp"
FileName = "whatever.xml"
Set XmlDocument = WScript.CreateObject("Msxml2.DOMDocument.3.0")
XmlDocument.async = False
Loaded = XmlDocument.load(FileName)
If Loaded Then
Set HttpRequest = WScript.CreateObject("Msxml2.XMLHTTP.3.0")
HttpRequest.open "POST", PostUrl, false
HttpRequest.send XmlDocument
If (HttpRequest.status = 200) Then
' succesful POST
' process response here e.g.
WScript.Echo HttpRequest.responseXML.xml
Else
' handle HTTP error here
WScript.Echo "Error: " & HttpRequest.status & " " &
HttpRequest.statusText
End If
End If
If you have already working code for HTTP but then with HTTPS problems
occur then maybe
<http://msdn.microsoft.com/library/d...MLHttpProxy.asp>
helps.
--
Martin Honnen
http://JavaScript.FAQTs.com/
| |
|
| I have attempted to use the snippet but found that the script does not post
the XML file. Is there anything special that needs to be set on the server
side to function correctly?
"Martin Honnen" wrote:
>
>
> David wrote:
>
>
> Pseudo code for VBScript Windows Script host file:
>
> Dim HttpRequest, PostUrl, XmlDocument, Loaded, FileName
> PostUrl = "https://example.com/2005/03/xmlupload.jsp"
> FileName = "whatever.xml"
>
> Set XmlDocument = WScript.CreateObject("Msxml2.DOMDocument.3.0")
> XmlDocument.async = False
> Loaded = XmlDocument.load(FileName)
> If Loaded Then
> Set HttpRequest = WScript.CreateObject("Msxml2.XMLHTTP.3.0")
> HttpRequest.open "POST", PostUrl, false
> HttpRequest.send XmlDocument
> If (HttpRequest.status = 200) Then
> ' succesful POST
> ' process response here e.g.
> WScript.Echo HttpRequest.responseXML.xml
> Else
> ' handle HTTP error here
> WScript.Echo "Error: " & HttpRequest.status & " " &
> HttpRequest.statusText
> End If
> End If
>
>
> If you have already working code for HTTP but then with HTTPS problems
> occur then maybe
> <http://msdn.microsoft.com/library/d...MLHttpProxy.asp>
> helps.
>
> --
>
> Martin Honnen
> http://JavaScript.FAQTs.com/
>
| |
| Joe Fawcett 2005-03-25, 6:34 pm |
| "David" <David@discussions.microsoft.com> wrote in message
news:12AB5546-C0EE-4529-B0FD-65E187CC7E77@microsoft.com...
>I have attempted to use the snippet but found that the script does not post
> the XML file. Is there anything special that needs to be set on the server
> side to function correctly?
>
No, it's nothing to do with the server whether it's posted, only whether it's
received and actioned. How is your jsp handling the request?
--
Joe (MVP - XML)
https://mvp.support.microsoft.com/p...E8-8741D22D17A5
| |
|
| The request doesnt even make it to the web server. Upon debugging the
script, i noticed that there is an error in the line:
HttpRequest.send XmlDocument
At this point the script gives me an error message:
msxml3.dll: The download of the specified resource has failed
That's where i'm stuck. Any ideas?
"Joe Fawcett" wrote:
> "David" <David@discussions.microsoft.com> wrote in message
> news:12AB5546-C0EE-4529-B0FD-65E187CC7E77@microsoft.com...
> No, it's nothing to do with the server whether it's posted, only whether it's
> received and actioned. How is your jsp handling the request?
>
>
> --
>
> Joe (MVP - XML)
>
> https://mvp.support.microsoft.com/p...E8-8741D22D17A5
>
>
>
| |
| Joe Fawcett 2005-03-25, 6:34 pm |
| "David" <David@discussions.microsoft.com> wrote in message
news:C006A738-F885-4086-8C4D-9B94C1AD3F8F@microsoft.com...
> The request doesnt even make it to the web server. Upon debugging the
> script, i noticed that there is an error in the line:
>
> HttpRequest.send XmlDocument
>
> At this point the script gives me an error message:
>
> msxml3.dll: The download of the specified resource has failed
>
> That's where i'm stuck. Any ideas?
>
>
Can you post the exact code you're using? Is the receiving page on the Web or an
intranet page?
--
Joe (MVP - XML)
https://mvp.support.microsoft.com/p...E8-8741D22D17A5
| |
|
| Here is the script below. As for the receiving page, i'm attempting to post
to an intranet. Thanks for your help!!
Dim HttpRequest, PostUrl, XmlDocument, Loaded, FileName
PostUrl = "https://{severname for posts}:8443/rtsaudit/upload/index.jsp"
FileName = "c:\Metrics.xml"
Set XmlDocument = WScript.CreateObject("Msxml2.DOMDocument.3.0")
XmlDocument.async = False
Loaded = XmlDocument.load(FileName)
If Loaded Then
Set HttpRequest = WScript.CreateObject("Msxml2.XMLHTTP.3.0")
HttpRequest.open "POST", PostUrl, false
HttpRequest.send XmlDocument
' If (HttpRequest.status = 200) Then
' succesful POST
' process response here e.g.
' WScript.Echo HttpRequest.responseXML.xml
' Else
' handle HTTP error here
' WScript.Echo "Error: " & HttpRequest.status & " "
'HttpRequest.statusText
' End If
End If
"Joe Fawcett" wrote:
> "David" <David@discussions.microsoft.com> wrote in message
> news:C006A738-F885-4086-8C4D-9B94C1AD3F8F@microsoft.com...
> Can you post the exact code you're using? Is the receiving page on the Web or an
> intranet page?
>
>
> --
>
> Joe (MVP - XML)
>
> https://mvp.support.microsoft.com/p...E8-8741D22D17A5
>
>
>
| |
|
| If i have a user credential for the https url would that make a difference?
"Joe Fawcett" wrote:
> "David" <David@discussions.microsoft.com> wrote in message
> news:C006A738-F885-4086-8C4D-9B94C1AD3F8F@microsoft.com...
> Can you post the exact code you're using? Is the receiving page on the Web or an
> intranet page?
>
>
> --
>
> Joe (MVP - XML)
>
> https://mvp.support.microsoft.com/p...E8-8741D22D17A5
>
>
>
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|