READ-XML Problem

kirsch59

Member
I'm running WebSpeed 10.1C on Windows 2008 server.

I'm trying to store XML data into a temp-table. The web service returns multiple records and they are not being stored in the temp-table.

Here's the temp-table definition:

def temp-table t-GetRootCategories undo
xml-node-name 'GetRootCategoriesResult'
field Description as char
field Id as char
field Name as char
field Parentid as char
index k-GetRootCategories is unique primary
Id ascending.

Here's a snippet of the XML response:

<GetRootCategoriesResponse>
<GetRootCategoriesResult >
<a:Category>
<a:Description />
<a:Id>03bf3128-cb61-463f-85df-8e132e22d693</a:Id>
<a:Name>Tape</a:Name>
<a:parentId>0</a:parentId>
</a:Category>
<a:Category>
<a:Description />
<a:Id>1d4c98a7-cbcd-48eb-aafc-069e7e05c983</a:Id>
<a:Name>Gloves</a:Name>
<a:parentId>0</a:parentId>
</a:Category>
<a:Category>
<a:Description />
<a:Id>10fa359f-f8f6-44a8-a05f-32d1ec1c73e3</a:Id>
<a:Name>Safety Items</a:Name>
<a:parentId>0</a:parentId>
</a:Category>
</GetRootCategoriesResult>
</GetRootCategoriesResponse>

I get a successful return code after doing the READ-XML method:

TEMP-TABLE t-GetRootCategories:READ-XML("FILE", filename , "EMPTY", ?, ?, ?, ?).

When I do a CAN-FIND (t-GetRootCategories...) it returns a true.

When I do the following:

for each t-GetRootCategories no-lock:
{&OUT}
"t-GetRootCategories.Description: ":U t-GetRootCategories.Description "<BR>"
"t-GetRootCategories.Id: ":U t-GetRootCategories.Id "<BR>"
"t-GetRootCategories.Name: ":U t-GetRootCategories.Name "<BR>"
"t-GetRootCategories.ParentId: ":U t-GetRootCategories.ParentId "<BR></BR>".
end.

The web page displays one records with no data:

t-GetRootCategories.Description:
t-GetRootCategories.Id:
t-GetRootCategories.Name:
t-GetRootCategories.ParentId

When I add a record to the temp-table by hardcoding a CREATE t-GetRootCategories and ASSIGN t-GetRootCategories and then do a READ-XML with option "MERGE" I see the hardcoded record but not the data from the XML response.

Is my temp-table definition correct?
 

Cringer

ProgressTalk.com Moderator
Staff member
If you put your code in [code][/code] tags it makes it easier to read for us. :)
 

kirsch59

Member
temp-table definition:

Code:
def temp-table t-GetRootCategories undo
     xml-node-name 'GetRootCategoriesResult'
             field Description  as char
             field Id  as char
             field Name  as char
             field Parentid  as char
       index k-GetRootCategories is unique primary 
              Id ascending.

XML Response:
Code:
- <GetRootCategoriesResponse xmlns="http://tempuri.org/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
- <GetRootCategoriesResult xmlns:a="http://schemas.datacontract.org/2004/07/Logicblock.Commerce.Domain" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
- <a:Category>
     <a:Description /> 
     <a:Id>03bf3128-cb61-463f-85df-8e132e22d693</a:Id> 
     <a:Name>Tape</a:Name> 
     <a:ParentId>0</a:ParentId> 
</a:Category>
- <a:Category>
     <a:Description /> 
     <a:Id>1d4c98a7-cbcd-48eb-aafc-069e7e05c983</a:Id> 
    <a:Name>Gloves</a:Name> 
     <a:ParentId>0</a:ParentId> 
</a:Category>
- <a:Category>
     <a:Description /> 
     <a:Id>10fa359f-f8f6-44a8-a05f-32d1ec1c73e3</a:Id> 
     <a:Name>Safety Items</a:Name> 
     <a:ParentId>0</a:ParentId> 
  </a:Category>
  </GetRootCategoriesResult>
</GetRootCategoriesResponse>

Display temp-table contents:
Code:
for each t-GetRootCategories no-lock:
   {&OUT}
      "t-GetRootCategories.Description: ":U t-GetRootCategories.Description "<BR>"
      "t-GetRootCategories.Id: ":U t-GetRootCategories.Id "<BR>"
      "t-GetRootCategories.Name: ":U t-GetRootCategories.Name "<BR>"
      "t-GetRootCategories.ParentId: ":U t-GetRootCategories.ParentId "<BR></BR>".
end.
 

kirsch59

Member
The plot thickens.

I'm able to display the last record of the XML file when I remove the data element
Code:
<a:Category>
</a:Category>

Code:
t-GetRootCategories.Description:
t-GetRootCategories.Id: 10fa359f-f8f6-44a8-a05f-32d1ec1c73e3
t-GetRootCategories.Name: Safety Items
t-GetRootCategories.ParentId: 0
 
Top