代码:
isc.RestDataSource.create({ ID: "restDS", dataFormat: "xml", fetchDataURL: "http://192.168.1.21:8282/uom/username=vikash%7C214057357158656/password=gbadmin/ModifiedOn=0", fields: [ {name:"UOMId"}, {name:"UOMCode"}, {name:"UOMName"} , {name:"UOMType"}, {name:"UOMNoOfDecimals"}, {name:"UOMStatus"} ] }); isc.ListGrid.create({ ID: "restList", width:800, height:224, alternateRecordStyles:true, dataSource: restDS, fields:[ {name:"UOMId"}, {name:"UOMCode"}, {name:"UOMName"} , {name:"UOMType"}, {name:"UOMNoOfDecimals"}, {name:"UOMStatus"} ], autoFetchData:true, autoDraw: true });
我在浏览器中遇到此错误
XML Parsing Error: no element found Location: moz-nullprincipal:{bc0868f9-b8df-4acd-b155-e58c50373d1b} Line Number 1, Column 1:
WebService内容
<ResponseJSON><Body><Datalist><UOMId>-1499999999</UOMId><UOMCode>MPM</UOMCode><UOMName>Meters Per Minute</UOMName><UOMType>2</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999997</UOMId><UOMCode>MM</UOMCode><UOMName>Milli Metres</UOMName><UOMType>0</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999996</UOMId><UOMCode>GSM</UOMCode><UOMName>Grammes per Square Metre</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999994</UOMId><UOMCode>LPM</UOMCode><UOMName>Litres Per Minute</UOMName><UOMType>2</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999993</UOMId><UOMCode>GRADE</UOMCode><UOMName>Grade</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999992</UOMId><UOMCode>GRAM</UOMCode><UOMName>Gram</UOMName><UOMType>1</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999991</UOMId><UOMCode>Degree</UOMCode><UOMName>Degree</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999990</UOMId><UOMCode>SET</UOMCode><UOMName>Set</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999989</UOMId><UOMCode>VOLT</UOMCode><UOMName>Volts</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999988</UOMId><UOMCode>AMPERE</UOMCode><UOMName>Ampere</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999987</UOMId><UOMCode>CELSIUS</UOMCode><UOMName>Celsius</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999986</UOMId><UOMCode>HZ</UOMCode><UOMName>Hertz</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999985</UOMId><UOMCode>HRS</UOMCode><UOMName>Hours</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999984</UOMId><UOMCode>LITERS</UOMCode><UOMName>Liters</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999983</UOMId><UOMCode>KWh</UOMCode><UOMName>KiloWatt Per Hour</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999982</UOMId><UOMCode>GRAVITY</UOMCode><UOMName>Gravity</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999981</UOMId><UOMCode>PRSR</UOMCode><UOMName>Pressure</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999980</UOMId><UOMCode>KVARh</UOMCode><UOMName>KVARh</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999979</UOMId><UOMCode>KVAh</UOMCode><UOMName>KVAh</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999978</UOMId><UOMCode>kVA</UOMCode><UOMName>kVA</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999977</UOMId><UOMCode>KW</UOMCode><UOMName>Kilo Watt</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999976</UOMId><UOMCode>VL</UOMCode><UOMName>V Line</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999975</UOMId><UOMCode>IL</UOMCode><UOMName>I Line</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999974</UOMId><UOMCode>TR</UOMCode><UOMName>TR</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999973</UOMId><UOMCode>PSIG</UOMCode><UOMName>PSIG</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999972</UOMId><UOMCode>FH</UOMCode><UOMName>Fahrenheit</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999971</UOMId><UOMCode>Y/N</UOMCode><UOMName>Y/N</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999970</UOMId><UOMCode>KL</UOMCode><UOMName>KL</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999969</UOMId><UOMCode>INR</UOMCode><UOMName>INR</UOMName><UOMType>1</UOMType><UOMNoOfDecimals>2</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999968</UOMId><UOMCode>RKVAH</UOMCode><UOMName>RKVAH</UOMName><UOMType>1</UOMType><UOMNoOfDecimals>2</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999967</UOMId><UOMCode>UNITS</UOMCode><UOMName>UNITS</UOMName><UOMType>1</UOMType><UOMNoOfDecimals>2</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999966</UOMId><UOMCode>SQFT</UOMCode><UOMName>SQFT</UOMName><UOMType>1</UOMType><UOMNoOfDecimals>2</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999965</UOMId><UOMCode>MTS</UOMCode><UOMName>Minutes</UOMName><UOMType>1</UOMType><UOMNoOfDecimals>2</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>269758049027601</UOMId><UOMCode>rt</UOMCode><UOMName>rt12</UOMName><UOMType>2</UOMType><UOMNoOfDecimals>1</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1500000000</UOMId><UOMCode>NOS</UOMCode><UOMName>Numbers</UOMName><UOMType>6</UOMType><UOMNoOfDecimals>3</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999998</UOMId><UOMCode>PPM</UOMCode><UOMName>Parts Per Million</UOMName><UOMType>3</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>-1499999995</UOMId><UOMCode>%</UOMCode><UOMName>Percentage</UOMName><UOMType>3</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>301246830151381</UOMId><UOMCode>cccc</UOMCode><UOMName>cccc</UOMName><UOMType>0</UOMType><UOMNoOfDecimals>1</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>306495824922361</UOMId><UOMCode>sd</UOMCode><UOMName>sd</UOMName><UOMType>1</UOMType><UOMNoOfDecimals>4</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>301243241629396</UOMId><UOMCode>asdf</UOMCode><UOMName>aaaa</UOMName><UOMType>0</UOMType><UOMNoOfDecimals>2</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist><Datalist><UOMId>545196525553078</UOMId><UOMCode>YTY</UOMCode><UOMName>QYRDY</UOMName><UOMType>1</UOMType><UOMNoOfDecimals>3</UOMNoOfDecimals><UOMStatus>1</UOMStatus></Datalist></Body><Status>200</Status><Total>41.0</Total></ResponseJSON>
plz帮助 谢谢
答案 0 :(得分:0)
您的webservice返回RestDataSource的错误响应。您可以在此处的文档中看到预期响应的示例:RestDataSource
您拥有的另一个选项是覆盖响应解析。在你的情况下,它将是这样的:
isc.RestDataSource.create({
ID: "restDS",
dataFormat: "xml",
fetchDataURL: "http://192.168.1.21:8282/uom/username=vikash%7C214057357158656/password=gbadmin/ModifiedOn=0",
xmlRecordXPath:"/ResponseJSON/Body/*",
fields: [
{name:"UOMId"},
{name:"UOMCode"},
{name:"UOMName"},
{name:"UOMType"},
{name:"UOMNoOfDecimals"},
{name:"UOMStatus"}
] ,
transformResponse : function (dsResponse, dsRequest, data) {
var totalRows = data.selectNumber("//Total");
if (totalRows != null) dsResponse.totalRows = totalRows;
var startRow = data.selectNumber("//startRow");
if (startRow != null) dsResponse.startRow = startRow;
var endRow = data.selectNumber("//endRow");
if (endRow != null) dsResponse.endRow = endRow;
return dsResponse;
}
});
请注意,我覆盖了xmlRecordPath属性和transformResponse方法。