Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
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
 
Old May 26th, 2008, 10:58 AM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Quote:
quote:

Well your code assumes the web service allows GET requests. If this is the case then you should be able to put the url, with the querystring variables in place, into your browser and see the XML returned.
I tried using the URL in web browser and it returns me the XML file.

Here is the XML which i get :

Quote:
quote:

  <?xml version="1.0" encoding="utf-8" ?>
- <returnMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.abcsite.com/">
  <ErrorName>Success</ErrorName>
  <ErrorDescription>Approved - Ready to be assigned to Order</ErrorDescription>
  <LeadID>13551728</LeadID>
  <ClientAvailable>true</ClientAvailable>
  </returnMessage>


 
Old May 26th, 2008, 11:08 AM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:

You also try to load the responseBody into a DomDocument, the responseBody is a byte array. You should be using the respon****ML or the responseText.
In ASP code ?

I tried

xmlDOM.load(xmlHttp.responseBody)

Can not load XML: End tag 'TD' does not match the start tag 'IMG'.

and Below that :

Page Not Found


 
Old May 26th, 2008, 11:19 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

No, don't use responseBody, use responseText or better still response-X-M-L (no dashes, stupid censor...)

--

Joe (Microsoft MVP - XML)
 
Old May 26th, 2008, 11:33 AM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default


I tried below code and it says

Page Not Found
Can not load XML: End tag 'TD' does not match the start tag 'IMG'.

Code:
   dpXML = httpReq.ResponseText
    Response.write dpXML

********************************************


I also tried below code and it says

???????????????????????????????????????•??????†¢????????????????????????????????????•?????????? •???????•??????????????/???????????????????•???????•???????•???????? ??????/???????????????????????????????????????•???????? ???????????????/?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ????????›?????????????????›???????????††† ??????5?????????????????????????????????????????? ???????????????????????????????›???????????????? ??????????????????5??????????????????????????????? ????????????????????????????????4????????????????? ?????????????????????????????????????????????????? ????????????›??????????????????????????????????? ?????????????????????????????????????????????????? ??????›?????????????????????????????4?5????????? ????????????????????????4????????????????????????? ????????????????????????????????????Can not load XML: Invalid at the top level of the document.


Code:
dpXML = httpReq.ResponseBody
Response.write dpXML
********************************************

I tried below code and it says

Can not load XML: XML document must have a top level element.

Code:
    dpXML = httpReq.ResponseBody
    myXmlDoc.load(httpReq.respon****ML)
    Set httpReq = Nothing
    If not  myXmlDoc.LoadXml(dpXML) Then
    ErrorMessage = "Can not load XML:" & vbCRLF &     myXmlDoc.parseError.reason & vbCRLF & ErrorMessage
    Response.write ErrorMessage
'    Response.write dpXML
    End If


 
Old May 26th, 2008, 11:36 AM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Sorry , may be I messed up the Code



 
Old May 26th, 2008, 12:12 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

It appears that the manual process is in two steps. You make a GET request to populate the form and then post the values to a service.
To do this in code you need to look at the html of the form, see where it's posting to and replicate the data posted using the names of the elements in the form.
You should be able to use the form's action to examine what the web service expects.
Just go to http://<domain name here>/Suppliers/WebServices/InsertLeads.asmx and click on the method name.

--

Joe (Microsoft MVP - XML)
 
Old May 26th, 2008, 12:14 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It's proving very difficult to help you, but this message

Can not load XML: End tag 'TD' does not match the start tag 'IMG'.

clearly means that you are retrieving HTML and trying to put it through the XML parser.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 26th, 2008, 12:47 PM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry If I am confusing you guys and take lot of time in explaining things.

My DATA form uses same Element name as

http://<domain name here>/Suppliers/WebServices/InsertLeads.asmx

Then it uses

Code:
<form action="http://<domain name here>/Suppliers/WebServices/InsertLeads.asmx/InsertLead" method="post" enctype="application/x-www-form-urlencoded" name="DP" id="DP">
and Its DISPLAYs me the XML as Output or Response from Server.

My IDEA is to capture XML and parse the data and display HTML.

My concern is how to "capture XML and parse the data and display HTML" in RUN TIME dynamically !!!

I dont want to display XML.


 
Old May 26th, 2008, 02:40 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

OK, firtly - if you are indeed simply trying to similate this PHP form in classic ASP, then this is the wrong forum, as this is an XML forum - and you're problems have nothing to do with XML at all, they are your lack of understanding of basic HTTP posting protocols.

In ASP you could however do something like this - note: the bosy of the post is what you would originally have put on the end of the URL.
The exact formats for both HTTP POST and HTTP GET are detailed at the bottom of the web services built in template (that Joe was referring to) here:
http://apps.doublepositive.com/Suppl...?op=InsertLead

Code:
Dim webServiceUrl, httpReq, node, myXmlDoc, postbody, xml

   webServiceUrl = "http://<domain name here>/Suppliers/WebServices/InsertLeads.asmx/InsertLead"

   postbody = "FirstName=Nita&LastName=Gower&City=hamton&State=CA&Phone=9515370000&LeadCreationDate=2008-05-17&TotalDebtAmount=25000&internalLeadID=30893&LeadCreationDate=2008-05-17"

   Set httpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
   httpReq.setRequestHeader("content-type", "application/www-form-urlencoded")
   httpReq.Open "POST", webServiceUrl, False
   httpReq.Send postbody

   xml = httpReq.ResponseText
Once you have the xml you can then process it using MSXML, much like you where trying to do:

Code:
    Set myXmlDoc = Server.CreateObject("MSXML2.DomDocument.3.0")
    myXmlDoc.async = False
    myXmlDoc.loadxml(xml)

    set node = myXmlDoc.SelectSingleNode("//ErrorDescription")
    Response.Write node.Text

/- Sam Judson : Wrox Technical Editor -/
 
Old May 26th, 2008, 03:08 PM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
<%

Dim webServiceUrl, httpReq, node, myXmlDoc, postbody, xml

   webServiceUrl = "http://apps.doublepositive.com/Suppliers/WebServices/InsertLeads.asmx/InsertLead"

'   postbody = "FirstName=Nita&LastName=Gower&City=hamton&State=CA&Phone=9515370000&LeadCreationDate=2008-05-17&TotalDebtAmount=25000&internalLeadID=30893&LeadCreationDate=2008-05-17"
    postbody="SupplierID=wefdg&SupplierPassword=3434&FirstName=string&LastName=string&EmailAddress=&CoAppFirstName=string&CoAppLastName=string&Address=string&City=string&State=string&PostalCode=232121&HomePhone=3108761232&WorkPhone=3108761232&WorkPhoneExt=string&CurrentEmployer=string&YearsThere=&Income=&BestCallTime=&OriginalLeadDate=12/12/2008&ExternalLeadID=23344&IPAddress=&ExtraFields=DebtAmount=10000"

   Set httpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
   httpReq.setRequestHeader "content-type", "application/www-form-urlencoded"
   httpReq.Open "POST", webServiceUrl, False
   httpReq.Send postbody

   xml = httpReq.ResponseText

    Set myXmlDoc = Server.CreateObject("MSXML2.DomDocument.3.0")
    myXmlDoc.async = False
    myXmlDoc.loadxml(xml)

    Set node = myXmlDoc.SelectSingleNode("//ErrorDescription")
    Response.Write node.text

%>
Above gives me an Error at

Quote:
quote:
msxml3.dll error '80004005'

Unspecified error

/debt/MyXML1.asp, line 11

Line 11 : httpReq.setRequestHeader "content-type", "application/www-form-urlencoded"







Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I load this xml to a dataset? chepla C# 2005 1 August 11th, 2008 08:51 AM
load XML issue AbrarNazeer XML 5 March 13th, 2008 09:43 AM
Load Xml From String ffbalota J2EE 0 January 24th, 2004 06:30 PM
Load Xml From String ffbalota JSP Basics 0 January 24th, 2004 06:29 PM
Load Xml From String ffbalota Apache Tomcat 0 January 24th, 2004 06:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.