2010-05-21 56 views
0

我需要一些幫助來理解如何解析j2me中的KSOAP響應。下面是 是我在製作ksoap請求後得到的實際ksoap響應。::如何解析KSOAP ARRAYTPE響應::

<AddressArray> 
    <AddressBin> 
     <UserSeqID>200</UserSeqID> 
     <AddressID>115</AddressID> 
     <ZipCode>10005</ZipCode> 
     <IsPrimary>false</IsPrimary> 
     <State>New York</State> 
     <StateID>37</StateID> 
     <StateCode>NY</StateCode> 
     <City>New York Mills village</City> 
     <CityID>11701</CityID> 
     <StreetAddress>90 feet rd</StreetAddress> 
     <NickName>Gym</NickName> 
    </AddressBin> 
    <AddressBin> 
     <UserSeqID>200</UserSeqID> 
     <AddressID>110</AddressID> 
     <ZipCode>10002</ZipCode> 
     <IsPrimary>false</IsPrimary> 
     <State>New York</State> 
     <StateID>37</StateID> 
     <StateCode>NY</StateCode> 
     <City>New York city</City> 
     <CityID>11700</CityID> 
     <StreetAddress>5th Street</StreetAddress> 
     <NickName>Home</NickName> 
    </AddressBin> 
    <AddressBin> 
     <UserSeqID>200</UserSeqID> 
     <AddressID>114</AddressID> 
     <ZipCode>10002</ZipCode> 
     <IsPrimary>true</IsPrimary> 
     <State>New York</State> 
     <StateID>37</StateID> 
     <StateCode>NY</StateCode> 
     <City>New York city</City> 
     <CityID>11700</CityID> 
     <StreetAddress>4th Street</StreetAddress> 
     <NickName>Office</NickName> 
    </AddressBin> 
</AddressArray> 

這裏是KSOAP響應模板

<AddressArray> 
     <AddressBin> 
     <UserSeqID>int</UserSeqID> 
     <AddressID>int</AddressID> 
     <ZipCode>string</ZipCode> 
     <IsPrimary>boolean</IsPrimary> 
     <State>string</State> 
     <StateID>int</StateID> 
     <StateCode>string</StateCode> 
     <City>string</City> 
     <CityID>int</CityID> 
     <StreetAddress>string</StreetAddress> 
     <NickName>string</NickName> 
     </AddressBin> 
     <AddressBin> 
     <UserSeqID>int</UserSeqID> 
     <AddressID>int</AddressID> 
     <ZipCode>string</ZipCode> 
     <IsPrimary>boolean</IsPrimary> 
     <State>string</State> 
     <StateID>int</StateID> 
     <StateCode>string</StateCode> 
     <City>string</City> 
     <CityID>int</CityID> 
     <StreetAddress>string</StreetAddress> 
     <NickName>string</NickName> 
     </AddressBin> 
    </AddressArray> 

請讓我知道我應該如何映射SOAP XML對輸入反應定製的Java類?

回答

1

我不知道它在J2ME中是如何工作的,但我在Android上做的是在SOAP響應中運行PropertyCount的大小(在您的情況下將是AddressArray的PropertyCount),訪問每個(在你的情況下AddressBin)的個人財產,然後再次訪問該屬性的每個屬性(你的情況UserSeqID,AddressID等),將它們放入一個字符串,解析那些所需的變量,並把這些變量在模型中並將這些模型放入數組中。

如果你想讓它們自動序列化,我不能幫你,因爲我不知道那是如何工作的。

希望這會有所幫助。