Handling SUDZC's response result-NSMutableArray

我的梦境 提交于 2019-12-13 02:37:16

问题


I am using SUDZC with a web service that responds with several different arrays: E_ANT, EFULLNAME, E_RULE, E_VACDAYS. But when I take a look into the request result there are only the values for the E_ANT visible. How can I access the other items or is this not possible with sudzc?

<n0:Z_COM_URL_GETRECORDSResponse xmlns:n0="urn:sap-com:document:sap:rfc:functions">
     <E_ANT>
        <item>
           <MANDT>010</MANDT>
           <USERID>00000016</USERID>
           <VAC_DATE>2012-01-09</VAC_DATE>
        </item>
        <item>
           <MANDT>010</MANDT>
           <USERID>00000016</USERID>
           <VAC_DATE>2012-02-01</VAC_DATE>
       </item>
      ....
       <item>
           <MANDT>010</MANDT>
           <USERID>00000016</USERID>
           <VAC_DATE>2012-03-15</VAC_DATE>
        </item>
     </E_ANT>
     <E_FULLNAME>Vanessa Martinez</E_FULLNAME>
     <E_RULE>
        <item>
           <MANDT>010</MANDT>
           <USERID>00000016</USERID>
           <DATE_FROM>2008-01-07</DATE_FROM>
           <DATE_TO>9999-12-31</DATE_TO>
           <VAC_ENTITLE>30.0</VAC_ENTITLE>
           <ERNAM_ID>00004001</ERNAM_ID>
           <ERDAT>2008-01-15</ERDAT>
        </item>
     </E_RULE>
     <E_VACDAYS>
        <MANDT>010</MANDT>
        <USERID>00000016</USERID>
        <KJAHR>2012</KJAHR>
        <VAC_THIS_YEAR>30.0</VAC_THIS_YEAR>
     </E_VACDAYS>
     <E_VACPAID/>
  </n0:Z_COM_URL_GETRECORDSResponse>

回答1:


My output was not in xml. Are you showing us the output from sudzc or the actual xml data? This is how I extracted my sudzc data

if( [value isKindOfClass:[NSError class]] || [value isKindOfClass:[SoapFault class]] ) 
{

NSLog(@"%@", [value description]);
return;
}

// Verify we're a dictionary
if( ![value isKindOfClass:[NSDictionary class]] ) {

NSLog(@"ERROR: Response not a dictionary");
return;
}

NSDictionary* dict = (NSDictionary*)value;
NSDictionary* resp = [dict objectForKey:@"E_AN"];
if( ( resp == nil ) || ![resp isKindOfClass:[NSDictionary class]] ) {

NSLog(@"ERROR: E_AN not a dictionary");
return;
}
dict = [resp objectForKey:@"item"];
if( ( dict == nil ) || ![dict isKindOfClass:[NSDictionary class]] ) {

NSLog(@"ERROR: item not a dictionary");
return;
}
resp = [dict objectForKey:@"MANDT"];
if( ( resp == nil ) || ![resp isKindOfClass:[NSDictionary class]] ) {

NSLog(@"ERROR: MANDT not a dictionary");
return;
}

...



来源:https://stackoverflow.com/questions/9829085/handling-sudzcs-response-result-nsmutablearray

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!