 |
| XML General XML discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 28th, 2004, 10:39 AM
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Retrieving XML created by a form
Hi All!
I've got a form that the user fills in, and then posts to an ASP page on the server. The server then creates an XML request dataset. I need to post the XML dataset created to a script on another sever via HTTPS, and retrieve the response into an XML dataset (variable in the ASP script).
I'm having trouble locating the right syntax/methods to do this in ASP (vbscript). I've seen references to a .load method, but I get an error (method not found) when I try to use it in the ASP code.
Can anyone give me an example of the VBScript code to send the XML to the remote server, and retrieve it into a XML object on the server?
Thanks!!
Sloan Thrasher
|
|

February 28th, 2004, 02:51 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
I'm not sure exactly how you want to create the datat set, here is an example that takes the username and town, wraps it in xml and posts to another server
Code:
Dim oDom
Set oDom = CreateObject("Msxml2.DomDocument.4.0")
Set oDom.documentElement = oDom.createElement("data")
Dim sName
Dim sTown
sName = Request("Name") 'Joe
sTown = Request("Town") 'Exeter
Dim oNameNode
Dim oTownNode
Set oNameNode = oDom.createElement("name")
oNameNode.text = sName
Set oTownNode = oDom.createElement("town")
oTownNode.text = sTown
oDom.documentElement.appendChild(oNameNode)
oDom.documentElement.appendChild(oTownNode)
The dom will now contain "<data><name>Joe</name><town>Exeter</town></data>".
Now to post to another server
Code:
Dim oHttpReq
Set oHttpReq = CreateObject("Msxml2.ServerXmlHttp.4.0");
oHttpReq.open "POST", <url here>, False
oHttpReq.send oRequestDom
If oHttpReq.status = 200 Then
'oHttpReq.responseXML now contains xml response
Else
'Error, check oHttpReq.statusText for more details
End
Joe (MVP - xml)
|
|

February 28th, 2004, 03:17 PM
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Joe!
Thanks. That filled in some of the blanks. I'm receiving the xml to send in Request.Form("xmldata"), so I presume that I use oDom.load to put it into oDom, right?
Also, the createobject lines in your example cause an error, so I assume XML 4 isn't on the server. It's a shared server, so I'll try the XML 2 versions...
Thanks!
Sloan
Sloan Thrasher
|
|

February 28th, 2004, 06:58 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
Quote:
|
quote:Thanks. That filled in some of the blanks. I'm receiving the xml to send in Request.Form("xmldata"), so I presume that I use oDom.load to put it into oDom, right?
|
If the only thing sent is xml data then just do
otherwise load the xml as a string
Code:
oDom.loadXML Request("xmlData")
Quote:
|
quote:Also, the createobject lines in your example cause an error, so I assume XML 4 isn't on the server. It's a shared server, so I'll try the XML 2 versions...
|
Try version 3,
Code:
Set oDom = CreateObject("Msxml2.DomDocument.3.0")
The advatage of version 4 is it's much more rekliable for server to server transfers. Nag your host to upgrade...
--
Joe
|
|

January 11th, 2006, 11:30 AM
|
|
Registered User
|
|
Join Date: Jan 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am working on this same issue, but need to take it a step further. I am able to send XML to another server. The other server then sends me a response back in XML. I need to take parts of that response and then place them into a recordset.
I have been able to do this from loading data from an actual XML document loaded on my server (with ServerMapPath), but not when sent back via POST. How can I do this?
|
|

January 15th, 2006, 12:22 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
The responseXML property of the XmlHttp request contains the xXML, you can extract results from that. In what form is the XML?
--
Joe ( Microsoft MVP - XML)
|
|

January 16th, 2006, 12:25 PM
|
|
Registered User
|
|
Join Date: Jan 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I understand the XML is now loaded into the response, but how to I extract individual values. For instance, the XML comes back wellformed:
<?xml version="1.0" encoding="UTF-8"?>
<EngineDocList>
<EngineDoc>
<MessageList>
<MaxSev DataType="S32">6</MaxSev>
<Message>
<AdvisedAction DataType="S32">16</AdvisedAction>
<Audience DataType="String">Merchant</Audience>
<Component DataType="String">CcxXmlInput.A</Component>
<ContextId DataType="String">CcxXmlInput</ContextId>
<DataState DataType="S32">1</DataState>
<FileLine DataType="S32">774</FileLine>
<FileName DataType="String">CcxXmlInstance.cpp</FileName>
<FileTime DataType="String">08:40:29Dec 29 2005</FileTime>
<ResourceId DataType="S32">35</ResourceId>
<Sev DataType="S32">6</Sev>
<Text DataType="String">The data 'CLIENTID' for element ClientId is not valid.</Text>
</Message>
</MessageList>
</EngineDoc>
</EngineDocList>
I need to be able to pull certain values and store into a SQL DB as well as base my business logic depending on the values in the XML tags. Any ideas?
|
|
 |