Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
Posts: 9
Registered: ‎05-20-2009
My Device: Not Specified

SOAPXML sample to get the xml result from the Dataset

[ Edited ]

I'm using the SOAPXML sample and modify some code to use our company own web services. However, I found when retreive the results using the follow code, it will show nothing value in the COST and AMOUNT.

 

if (QString::compare("true", responseValue["Success"].toString(), Qt::CaseInsensitive) == 0) {
        m_succeeded = true;
        m_error.clear();

        m_temperature = responseValue["COST"].toString();
        m_description = responseValue["AMOUNT"].toString();
        emit temperatureChanged();
        emit descriptionChanged();
     else {
       m_succeeded = false;
        m_error = responseValue["ResponseText"].toString();
    }

 

I compare the XML output file from weatherService and our own services. It seem the output format is different.

 

WeatherServices:

  <?xml version="1.0" encoding="utf-8" ?>
  <Success>true</Success>
  <ResponseText>City Found</ResponseText>
  <State>TX</State>
  <City>Conroe</City>
  <WeatherStationCity>Conroe</WeatherStationCity>
  <WeatherID>14</WeatherID>
  <Description>Cloudy</Description>
  <Temperature>45</Temperature>
  <RelativeHumidity>89</RelativeHumidity>
  <Wind>CALM</Wind>
  <Pressure>30.15S</Pressure>
  <Visibility />
  <WindChill />
  <Remarks />
  </WeatherReturn>
 
 
My Own Services:
  <?xml version="1.0" encoding="utf-8" ?>
- <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xs:element name="NewDataSet" msdata&colon;IsDataSet="true" msdata&colon;UseCurrentLocale="true">
- <xs:complexType>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element name="Table1">
- <xs:complexType>
- <xs:sequence>
  <xs:element name="SHOPID" type="xs:string" minOccurs="0" />
  <xs:element name="SHOPNAME" type="xs:string" minOccurs="0" />
  <xs:element name="QTY" type="xs:decimal" minOccurs="0" />
  <xs:element name="COST" type="xs:string" minOccurs="0" />
  <xs:element name="AMOUNT" type="xs:string" minOccurs="0" />
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:choice>
  </xs:complexType>
  </xs:element>
  </xs:schema>
- <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
- <NewDataSet xmlns="">
- <Table1 diffgr:id="Table11" msdata&colon;rowOrder="0" diffgr:hasChanges="inserted">
  <SHOPID>1111</SHOPID>
  <SHOPNAME>AAA Sop</SHOPNAME>
  <QTY>629</QTY>
  <COST>400906</COST>
  <AMOUNT>474246</AMOUNT>
  </Table1>
  </NewDataSet>
  </diffgr:diffgram>
  </DataSet>
 
I noticed mine one like as a table using the <DataSet> and have rowOrder (Sometimes I need get multiple records), How can I get those value (multiple records) which is insided in the DataSet?

 

Developer
Posts: 16,583
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: SOAPXML sample to get the xml result from the Dataset

i use QtSoap, so i can only answer for that.
you can work with QtSoapStruct and QtSoapArray to parse complex responses.

 

QtSoapStruct &soapStruct = (QtSoapStruct &) resp.method();
QtSoapArray &attributes = (QtSoapArray &) soapStruct["Attributes"];
for (int i = 0; i < attributes.count(); ++i) {
	QtSoapStruct &item = (QtSoapStruct &) attributes[i];
QString attributeName = item["Attributename"].toString().toLower(); //... }

 

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter