 |
| 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
|
|
|
|

May 26th, 2008, 03:13 PM
|
|
Authorized User
|
|
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Does it mean that My server doesnt support XML ?
|
|

May 26th, 2008, 03:28 PM
|
|
Authorized User
|
|
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
If I comment :
httpReq.setRequestHeader "content-type", "application/www-form-urlencoded"
then it gives me an Error at
Response.Write node.text
as
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required
/XML/MyXML1.asp, line 22
|
|

May 26th, 2008, 04:12 PM
|
|
Authorized User
|
|
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Code:
If not myXmlDoc.LoadXml(xml) Then
ErrorMessage = "Can not load XML:" & vbCRLF & myXmlDoc.parseError.reason & vbCRLF & ErrorMessage
Response.write ErrorMessage
End If
If I add above code to debug, it returns me :
Can not load XML: Invalid at the top level of the document.
|
|

May 26th, 2008, 04:21 PM
|
|
Authorized User
|
|
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
An observation :
I simply tried one URL :
http://starbulletin.com/rss/edition.xml
and It works.
Code:
<%
Dim webServiceUrl, httpReq, node, myXmlDoc, postbody, xml
webServiceUrl="http://starbulletin.com/rss/edition.xml"
Set httpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
httpReq.Open "POST", webServiceUrl, False
httpReq.Send
xml = httpReq.ResponseText
Set myXmlDoc = Server.CreateObject("MSXML2.DomDocument.3.0")
myXmlDoc.async = False
myXmlDoc.loadxml(xml)
If not myXmlDoc.LoadXml(xml) Then
ErrorMessage = "Can not load XML:" & vbCRLF & myXmlDoc.parseError.reason & vbCRLF & ErrorMessage
Response.write ErrorMessage
End If
Set node = myXmlDoc.SelectSingleNode("//title")
Response.Write node.text
%>
Does it mean that XML which i am getting from server has Issues and not my ASP code ?
|
|

May 26th, 2008, 04:24 PM
|
|
Authorized User
|
|
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Here is the XML I get from my server :
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.doublepositive.com/">
<ErrorName>Lead Import Error.</ErrorName>
<ErrorDescription>The underlying connection was closed: An unexpected error occurred on a receive.. Your lead has not been imported. Please review system documentation for required fields and data types. For further help please call xxx-332-0464.</ErrorDescription>
<LeadID />
<ClientAvailable>true</ClientAvailable>
</returnMessage>
|
and even if XML file has Errors ,how ignore/bypass the Error and get the correct node.text ?
|
|

May 26th, 2008, 04:32 PM
|
|
Authorized User
|
|
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Server which returns me the XML file, I have downloaded and saved that XML from that server and
Tried directly to see whether it works or not
Quote:
quote:
<%
Dim webServiceUrl, httpReq, node, myXmlDoc, postbody, xml
webServiceUrl="http://clearmybaddebt.com/InsertLead.xml"
Set httpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
httpReq.Open "POST", webServiceUrl, False
httpReq.Send
xml = httpReq.ResponseText
Set myXmlDoc = Server.CreateObject("MSXML2.DomDocument.3.0")
myXmlDoc.async = False
myXmlDoc.loadxml(xml)
If not myXmlDoc.LoadXml(xml) Then
ErrorMessage = "Can not load XML:" & vbCRLF & myXmlDoc.parseError.reason & vbCRLF & ErrorMessage
Response.write ErrorMessage
End If
Set node = myXmlDoc.SelectSingleNode("//ErrorName")
Response.Write node.text
%>
|
But it give some an error at line
Microsoft VBScript runtime (0x800A01A8)
Object required
/XML/MyXML1.asp, line 20
Line 20 is :
Set node = myXmlDoc.SelectSingleNode("//ErrorName")
Response.Write node.text
It means that there is No node as "ErrorName".
But if you try to Open http://clearmybaddebt.com/InsertLead.xml directly from browser, it shows
Code:
<?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.doublepositive.com/">
<ErrorName>Lead Import Error.</ErrorName>
<ErrorDescription>The underlying connection was closed: An unexpected error occurred on a receive.. Your lead has not been imported. Please review system documentation for required fields and data types. For further help please call XXX-332-0464.</ErrorDescription>
<LeadID />
<ClientAvailable>true</ClientAvailable>
</returnMessage>
Where Node ErrorName is
<ErrorName>Lead Import Error.</ErrorName>
Kindly advice.
|
|

May 27th, 2008, 12:27 AM
|
|
Authorized User
|
|
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sorry for this lenghty discussion
|
|

May 27th, 2008, 08:12 AM
|
|
Authorized User
|
|
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Kindly advice if any other test I can try.
|
|

May 27th, 2008, 09:16 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
There appears to be a problem with the POSTside of things on the server, nothing to do with your code. I don't have the ability to test in ASP at the moment but the following VBScript code works, just save it as a .vbs file to run it:
Code:
Option Explicit
Dim url
url = "http://apps.doublepositive.com/Suppliers/WebServices/InsertLeads.asmx/InsertLead"
Private Function InsertLead(SupplierId, SupplierPassword, FirstName, LastName, EmailAddress, CoAppFirstName, CoAppLastName, Address, City, State, PostalCode, HomePhone, WorkPhone, WorkPhoneExt, CurrentEmployer, YearsThere, Income, BestCallTime, OriginalLeadDate, ExternalLeadID, IPAddress, ExtraFields)
Dim queryString
queryString = "SupplierID=" & SupplierId
queryString = queryString & "&SupplierPassword=" & SupplierPassword
queryString = queryString & "&FirstName=" & FirstName
queryString = queryString & "&LastName=" & LastName
queryString = queryString & "&EmailAddress=" & EmailAddress
queryString = queryString & "&CoAppFirstName=" & CoAppFirstName
queryString = queryString & "&CoAppLastName=" & CoAppLastName
queryString = queryString & "&Address=" & Address
queryString = queryString & "&City=" & City
queryString = queryString & "&State=" & State
queryString = queryString & "&PostalCode=" & PostalCode
queryString = queryString & "&HomePhone=" & HomePhone
queryString = queryString & "&WorkPhone=" & WorkPhone
queryString = queryString & "&WorkPhoneExt=" & WorkPhoneExt
queryString = queryString & "&CurrentEmployer=" & CurrentEmployer
queryString = queryString & "&YearsThere=" & YearsThere
queryString = queryString & "&Income=" & Income
queryString = queryString & "&BestCallTime=" & BestCallTime
queryString = queryString & "&OriginalLeadDate=" & OriginalLeadDate
queryString = queryString & "&ExternalLeadID=" & ExternalLeadID
queryString = queryString & "&IPAddress=" & IPAddress
queryString = queryString & "&ExtraFields=" & ExtraFields
Dim httpReq
Set httpReq = CreateObject("msxml2.serverxmlhttp.4.0")
httpReq.Open "GET", url & "?" & queryString, false
httpReq.Send
Set InsertLead = httpReq
End Function
Public Sub Main()
Dim req
Set req = InsertLead("aaaa", "bbbb", "Joe", "Bloggs", "[email protected]", "Fred", "Smith", "123 High Street", "Springfield", "WA", "12345", "123456789", "123456789", "123", "ACME", "3", "", "", "", "", "", "")
WScript.Echo req.Status
WScript.Echo req.ResponseText
End Sub
Call Main()
(You may need to remove inadvertent line breaks)
You should be able to transfer to asp, just change WScript.Echo to Response.Write.
--
Joe ( Microsoft MVP - XML)
|
|

May 27th, 2008, 09:41 AM
|
|
Authorized User
|
|
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Code:
There appears to be a problem with the POSTside of things on the server,
Can you tell me what the problem on the server side so that I can ask Server Adminsitrator to look into the same and "may be"[If he/she accepts] we can get it resolve ?
|
|
 |