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 25th, 2008, 08:54 PM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can not load XML

I am getting below Error whem I am tryin to process below code :

Can not load XML: A string literal was expected, but no opening quote character was found


 
Quote:
quote:
Quote:
<%

Call consumeWebService

Sub consumeWebService

    Dim webServiceUrl, httpReq, node, myXmlDoc

    webServiceUrl = "http://www.clearmybaddebt.com/debt/reports/generateLeadID.asp?FirstName=TOM&LastName=SCOTT&Ci ty=MIAMI&State=FL&Phone=7863267522&LeadCreationDat e=5/16/2008&TotalDebtAmount=13000&internalLeadID=19721&Le adCreationDate=5/16/2008"

    Set httpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")

    httpReq.Open "GET", webServiceUrl, False
    httpReq.Send
    dpXML = httpReq.ResponseText
    Set myXmlDoc =Server.CreateObject("MSXML2.DomDocument.3.0")
    myXmlDoc.async = False
    myXmlDoc.validateOnParse = False
    myXmlDoc.resolveExternals = False
    myXmlDoc.load(httpReq.responseBody)
    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
    Set httpReq = Nothing ' clear HTTP object
    Set RSSItems = myXmlDoc.getElementsByTagName("ErrorDescription")
    RSSItemsCount = RSSItems.Length-1
    Set myXmlDoc = Nothing ' clear XML
    For i = 0 To RSSItemsCount
       Set RSSItem = RSSItems.Item(i)
    for each child in RSSItem.childNodes
    Select case lcase(child.nodeName)
        case "ErrorDescription"
            Response.write child.text
            Response.write ErrorMessage
    End Select
    next
     next

End Sub

%>


I am also getting an Error :

Can not load XML: End tag 'HEAD' does not match the start tag 'META'.


ErrorMessage = "Can not load XML:" & "<br>" & xmlDOM.parseError.reason & "<br>" & "ErrorCodce-" & xmlDOM.parseError.errorCode & "<br>" & "Error Line Number-" & xmlDOM.parseError.LINE

Above line Returns me :


Quote:

Can not load XML:
End tag 'HEAD' does not match the start tag 'META'.
ErrorCodce--1072896659
Error Line Number-11


Line 11 is :

Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP")

Is this Line 11 of ASP Code or Line 11 f XML document ?

 
Old May 26th, 2008, 03:45 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>Can not load XML: A string literal was expected, but no opening quote character was found

Well, that's pretty clearly saying that something is wrong with your XML, not with your ASP code, so why are you showing us your ASP code amd not your XML?

>Can not load XML: End tag 'HEAD' does not match the start tag 'META'.

That looks very much as if the "XML" you are trying to load is not XML at all, but HTML.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 26th, 2008, 03:54 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

... which could point to the file being served as HTML rather than text/xml, i.e. the wrong content type is being set on the server.

--

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

Here is the File I am being shown as XML :

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>Lead Import Error.</ErrorName>

<ErrorDescription>Invalid Login Attempt. Your lead has not been imported. Please review system documentation for required fields and data types. For further help please call xxx-xxx-xxxx.</ErrorDescription>

<LeadID />

<ClientAvailable>true</ClientAvailable>

</returnMessage>

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

Well to be honest that's obviously not the XML that is returned causing the second error is it - it doesn't contain either an HTML or META element. That error is likely caused when an error page is returned by the web service you are calling.


As for this one - there appears to be quotes missing from around the xmlns=http://www.abcsite.com which should be xmlns="http://www.abcsite.com". I don't know if that is a cut and paste error or not.



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

Server which returns me XML, C# Instructions which can be used to get back HTML instead of XML:
************************************************** *******************

Quote:
quote:


ABCSite.InsertLeads tsRealTimeWS = new ABCSite.InsertLeads();
ABCSite.returnMessage tsReturnWS = new ABCSite.returnMessage();

tsReturnWS = tsRealTimeWS.InsertLead(
Request.Form["txtSupplierID"],Request.Form["txtSupplierPassword"], Request.Form["txtFirstName"], Request.Form["txtLastName"],
Request.Form["txtCoAppFirstName"], Request.Form["txtCoAppLastName"],
Request.Form["txtCity"], Request.Form["txtState"], Request.Form["txtPostalCode"], Request.Form["txtHomePhone"], Request.Form["txtWorkPhone"], Request.Form["txtWorkPhoneExt"], Request.Form["txtBestCallTime"], Request.Form["txtEmailAddress"], Request.Form["txtOriginalLeadDate"],Request.Form["txtExternalLeadID"], Request.Form["txtIPAddress"], Request.Form["txtExtraFields"]);

lblWSResponse.Text = tsReturnWS.ErrorName + " " + tsReturnWS.ErrorDescription;
Asked to use Instructions from below page to design C# page

http://www.sitepoint.com/article/net...rvices-5-steps
 
Old May 26th, 2008, 04:29 AM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Sorry, Its a CUT and PASTE Error :

It should be "www.abcsite.com/"


Instruction in Server Document :

Quote:
quote:

HTTP POST
The following is a sample HTTP POST request and response. The placeholders shown need to be replaced with actual values.

POST /Suppliers/WebServices/InsertLeads.asmx/InsertLead HTTP/1.1
Host: apps.abcsite.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length

SupplierID=string&SupplierPassword=string&FirstNam e=string&LastName=string&EmailAddress=string&CoApp FirstName=string&CoAppLastName=string&Address=stri ng&City=string&State=string&PostalCode=string&Home Phone=string&WorkPhone=string&WorkPhoneExt=string& CurrentEmployer=string&YearsThere=string&Income=st ring&BestCallTime=string&OriginalLeadDate=string&E xternalLeadID=string&IPAddress=string&ExtraFields= string
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<returnMessage xmlns="http://www.abcsite.com/">
  <ErrorName>string</ErrorName>
  <ErrorDescription>string</ErrorDescription>
  <LeadID>string</LeadID>
  <ClientAvailable>boolean</ClientAvailable>
</returnMessage>

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

As suggested previously you need to add:
Code:
Response.ContentType = "text/xml" before returning the content. You can add this in code or using the ContentType attribute in the aspx file.
--

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


I have to add

Response.ContentType = "text/xml"

in my above ASP Code, not asmx ?

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

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/xml/MyXML.asp, line 15, column 14
Set xmlDOM =Server.CreateObject("MSXML2.DomDocument.3.0")
-------------------------------------------^







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.