Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 6 of 6

Thread: WSI Results as Invalid XML Document

  1. #1
    cjbarth is offline Senior Member
    Join Date
    Oct 2008
    Posts
    392

    Exclamation WSI Results as Invalid XML Document

    I'm submitting a very simple query to WSI and am getting a reply that is malformed.

    I submit the following code:

    <AspDotNetStorefrontImport Version="7.1" SetImportFlag="true" AutoLazyAdd="true" AutoCleanup="true" Verbose="true" TransactionsEnabled="false">
    <Query Name="cae42174-ee12-4725-b8c4-d2a183b52afc" RowName="3ef1a4d9-e709-4e4a-a6c5-eeab38b0454b">
    <SQL>SELECT COUNT(*) FROM Category WHERE CategoryID = 1690</SQL>
    </Query>
    </AspDotNetStorefrontImport>

    I get the following response:

    <?xml version="1.0" encoding="utf-16"?>
    <AspDotNetStorefrontImportResult Version="7.1" DateTime="3/19/2010 9:57:52 AM">
    <Verbose Message="Import Starting" />
    <Verbose Message="Processing Query, Name=cae42174-ee12-4725-b8c4-d2a183b52afc, RowName=3ef1a4d9-e709-4e4a-a6c5-eeab38b0454b" /><Query Name="cae42174-ee12-4725-b8c4-d2a183b52afc"><Verbose Message="SQL=select count(*) from category where categoryid = 1690" /><3ef1a4d9-e709-4e4a-a6c5-eeab38b0454b><>1</></3ef1a4d9-e709-4e4a-a6c5-eeab38b0454b></Query><Verbose Message="Import Completed" /></AspDotNetStorefrontImportResult>

    I've created an XmlDocument object and have tried populating it with the .Load and .LoadXml methods and have received errors with both methods:

    .Load Error:

    ArgumentException - Illegal characters in path.

    .LoadXml Error:

    XmlException - Name canot begin with the '3' character, hexadecimal value 0x34. Line 4, position 261.

    I even tried using a non-numeric string for my RowName and that didn't change my results much. Instead of getting an error saying that Name can't begin with a number I get an error that says that Name can begin with a '>'. That is the real bug that I'm dealing with because no matter what I do I always get results like:

    <>1</>

    Which, no matter how you look at it, is invalid XML. Thus I think there is a bug in the WSI processor.

  2. #2
    cjbarth is offline Senior Member
    Join Date
    Oct 2008
    Posts
    392

    Default

    If a change is made to DB.vb in the ASPDNSFCore project this problem can be solved.

    It seems that if there is no name on the field then no value is given for the element name, which is a problem that results in invalid XML code.

    If line 1601 is changed from:

    Dim elname As String = dr.GetName(i).Replace(" ", "_")

    to

    Dim elname As String = If(dr.GetName(i) = "", "Column_" & i, dr.GetName(i).Replace(" ", "_"))

    the problem is resolved. I'm not sure of any other implications of this, but I would imagine that since the code that you have will generate invalid XML in every instance where there is no field name that this change can only yield positive results.

  3. #3
    cjbarth is offline Senior Member
    Join Date
    Oct 2008
    Posts
    392

    Default

    I haven't done this, but I suggest that WSI.vb be modified to disallow any RowNames that begin with or contain invalid characters.

  4. #4
    George the Great is offline Senior Member
    Join Date
    Nov 2006
    Location
    Cleveland, OH
    Posts
    1,792

    Default

    WSI was meant as a data-access/retrieval/update and integration tool (though it can be used just for simple queries as well) , so it doesn't make much sense to support nodes with no names or you wouldn't know how to access the data in other systems that are using the XML. In your case, just add a simple as clause, eg.
    Code:
    SELECT COUNT(*) as N FROM Category WHERE CategoryID = 1690
    or
    Code:
    SELECT COUNT(*) as Count FROM Category WHERE CategoryID = 1690
    which results in <n>#</n> or <count>#</count>
    <a href="http://www.aspdotnetstorefront.com">Shopping Cart Software</a>

  5. #5
    cjbarth is offline Senior Member
    Join Date
    Oct 2008
    Posts
    392

    Default

    I appreciate that update and suggestion.

    You might consider implementing the change that I made so that you can avoid this problem in the future. It isn't so much a matter of supporting such-and-such as it is always returning valid XML code.

  6. #6
    cjbarth is offline Senior Member
    Join Date
    Oct 2008
    Posts
    392

    Default

    In v9.0.1.3 the line number is 1696 in the GetXML(Data.IDataReader, String, String, Boolean, ByRef Text.StringBuilder) routine.
    ML9.3.1.1
    SQL 2012 Express
    VS 2010
    Azure VM