0
我有使用Sudzc(ARC分支)解析肥皂響應的問題。我有一些WCF服務爲我們的應用程序存儲數據。我設法連接到web服務,我可以成功地得到響應,但是當有一個響應帶有z:ref屬性時,我被卡住了。沒有一個例子很難解釋嗎? ;)/我已經替換爲例如「#someid」重要的數據,所以不要點,這是一個問題;)閱讀複雜肥皂響應,ID和IDREFs節點與Sudzc [iOS]
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<ActivityId>#some credentials </ActivityId>
</s:Header>
<s:Body>
<GetMessagesResponse >
<GetMessagesResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<AllItemsCount>2</AllItemsCount>
<Items>
<Message z:Id="i1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
<GlobalId>#msgid</GlobalId>
<Content>bbbbbbbb</Content>
<CreatedDate>2013-02-14T16:33:07</CreatedDate>
<Priority>Normal</Priority>
<Receiver z:Id="i2">
<GlobalId>#receiverid</GlobalId>
<CountryId>37</CountryId>
<CreationDate>2013-01-31T16:12:40</CreationDate>
<Gender>Male</Gender>
<IsDeleted>false</IsDeleted>
<Picture i:nil="true" />
<UserName>tobiasz</UserName>
</Receiver>
<Sender z:Id="i3">
<GlobalId>#senderid</GlobalId>
<CountryId>6</CountryId>
<CreationDate>2013-02-04T13:08:40</CreationDate>
<Gender>Male</Gender>
<IsDeleted>false</IsDeleted>
<Picture >
#"picture info"
</Picture>
<UserName>tobiasz2</UserName>
</Sender>
<Topic>RE: 56765765</Topic>
</Message>
<Message z:Id="i4" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
<GlobalId>#msgid2</GlobalId>
<Content>aaaaaaa</Content>
<CreatedDate>2013-02-14T16:31:01</CreatedDate>
<Priority>High</Priority>
<Receiver z:Ref="i2"/>
<Sender z:Ref="i3"/>
<Topic>RE: 56765765</Topic>
</Message>
</Items>
<PageIndex>0</PageIndex>
<RetrievedDateTime>2013-02-15T13:14:57.0813487Z</RetrievedDateTime>
</GetMessagesResult>
</GetMessagesResponse>
</s:Body>
,你可以看到有標識接收機節點I2線 並且還可以看到另一個消息的節點來自相同的發送者和以同一接收器
sudzc生成的類用於解析該XML:
@interface ResultOfGetMessages : SoapObject{
int _AllItemsCount;
NSMutableArray* _Items;
int _PageIndex;
NSDate* _RetrievedDateTime;
}
@interface Message : WSGlobalObject{
NSString* _Content;
NSDate* _CreatedDate;
NSString* _Priority;
User* _Receiver;
User* _Sender;
NSString* _Topic;
}
@interface User : WSGlobalObject{
int _CountryId;
NSDate* _CreationDate;
NSString* _Gender;
BOOL _IsDeleted;
PictureInfo* _Picture;
NSString* _UserName;
}
<ResultOfGetMessages>
<AllItemsCount>2</AllItemsCount>
<Items>
<Message>
<GlobalId>###</GlobalId>
<Content>bbbbbbbb</Content>
<CreatedDate>2013-02-14T16:33:07.000</CreatedDate>
<Priority>Normal</Priority>
<Receiver>
<GlobalId>####</GlobalId>
<CountryId>37</CountryId>
<CreationDate>2013-01-31T16:12:40.000</CreationDate>
<Gender>Male</Gender>
<IsDeleted>false</IsDeleted>
<Picture i:nil="true" ></Picture>
<UserName>tobiasz</UserName>
<Version>11</Version>
</Receiver>
<Sender>
<GlobalId>e4bda93c-a11c-4ae2-baf1-a15b00e918e7</GlobalId>
<CountryId>6</CountryId>
<CreationDate>2013-02-04T13:08:40.000</CreationDate>
<Gender>Male</Gender>
<IsDeleted>false</IsDeleted>
<Picture >
####
</Picture>
<UserName>tobiasz2</UserName>
<Version>11</Version>
</Sender>
<Topic>RE: 56765765</Topic>
</Message>
<Message>
<GlobalId>###</GlobalId>
<Content>aaaaaaa</Content>
<CreatedDate>2013-02-14T16:31:01.000</CreatedDate>
<Priority>High</Priority>
<Receiver>
<CountryId>0</CountryId>
<IsDeleted>false</IsDeleted>
</Receiver>
<Sender>
<CountryId>0</CountryId>
<IsDeleted>false</IsDeleted>
</Sender>
<Topic>RE: 56765765</Topic>
</Message>
</Items>
<PageIndex>0</PageIndex>
我認爲問題奠定在反序列化的深度:Sudz與Touchxml無法讀取(獲得空接收器和發送器),爲響應解析。解析器(if)試圖使用指定的id來獲取接收者節點,但它失敗了,因爲用此id標記的接收者節點在其他節點(前一個節點)中。
在此先感謝您的幫助和您的時間。
Tahnks答覆。我想通過收集具有ID的節點來解決這個問題,並將其數據填充到空的節點並具有IDREF。從ID'ed節點收集的數據存儲在數據庫中。所以比你的解決方案有點複雜;) 我讀過代碼,它看起來很簡單,很有希望。 現在我正在開發其他項目,我可能會在1月13日回到它,我要測試你的解決方案。再次感謝 ! – cbr 2013-11-29 12:40:15