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, 03:13 PM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Does it mean that My server doesnt support XML ?

 
Old May 26th, 2008, 03:28 PM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old May 26th, 2008, 04:12 PM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default


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.


 
Old May 26th, 2008, 04:21 PM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 ?


 
Old May 26th, 2008, 04:24 PM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 ?
 
Old May 26th, 2008, 04:32 PM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default


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.
 
Old May 27th, 2008, 12:27 AM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Kindly advice if any other test I can try.

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

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)
 
Old May 27th, 2008, 09:41 AM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 ?






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.