PDA

View Full Version : Parsing XML data with multiple elements from asp.net web service



btomar
10 Mar 2011, 8:43 AM
Hello,

I have recently started using ExtJS and have come across few doubts which could not be cleared with the documentation or the forums. Maybe I am getting it all wrong but I would appreciate if someone could shed some light here.

I am trying to call a .asmx (.net) webservice which has xml schema as follow:



<xs:schema id="myDataSet">
?
<xs:element name="myDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
?
<xs:complexType>
?
<xs:choice minOccurs="0" maxOccurs="unbounded">
?
<xs:element name="solutionCost">
?
<xs:complexType>
?
<xs:sequence>
<xs:element name="Cost_x0020_Type" type="xs:string" minOccurs="0"/>
<xs:element name="Total_x0020_Cost" type="xs:double" minOccurs="0"/>
<xs:element name="Cost_x0020_per_x0020_Gallon" type="xs:double" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
?
<xs:element name="solutionRefinery">
?
<xs:complexType>
?
<xs:sequence>
<xs:element name="Refinery_x0020_ID" type="xs:int" minOccurs="0"/>
<xs:element name="Refinery_x0020_Type_x0020_ID" type="xs:int" minOccurs="0"/>
<xs:element name="Tons_x0020_Processed" type="xs:double" minOccurs="0"/>
<xs:element name="Gallons_x0020_Produced" type="xs:double" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
?
<xs:element name="solutionTerminal">
?
<xs:complexType>
?
<xs:sequence>
<xs:element name="Terminal_x0020_ID" type="xs:int" minOccurs="0"/>
<xs:element name="Name" type="xs:string" minOccurs="0"/>
<xs:element name="Gallons_x0020_Processed" type="xs:double" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>


My questions are:

1) To fetch the xml data from these elements, do I need to write multiple xmlreader calls? For eg. one call each for the solutionCost, solutionRefinery and solutionTerminal elements? Is there a way to read multiple elements from xml schema within the same call?
2) I also need to include authentication header with my request, will that go in params within the Store object?
3) The webservice on asp.net only talks on XML/SOAP, and does not return JSON data. Is there a way to enable that?

I would appreciate any suggestions/advice in helping me nailing this down.

Thanks,

Bhuvanesh