0
我想使用RestKit解析SOAP响应。如果我自己定义映射和关系,我能够成功地将SOAP XML响应转换为对象。但是,我想知道是否可以使用自省(或其他)来自动将SOAP XML响应转换为Objective-C对象。使用introspection restkit的对象映射
示例XML:
<return>
<userId xsi:type="xsd:int">1113050187</userId>
<location xsi:type="ns1:Location">
<city xsi:type="xsd:string">San Francisco</city>
<state xsi:type="xsd:string">California</state>
</location>
</return>
我想这个XML转换成该对象:
@interface Return : NSObject
@property (strong, nonatomic) NSInteger userId; // attribute
@property (strong, nonatomic) Location *location; // relation
@end
我能想出用在返回类的自省来获取所有最接近的事属性和使用类似这样的每个属性: [映射addAttributeMapping:[RKObjectAttributeMapping mappingFromKeyPath:@“userId.text”toKeyPath:@“userId”]];
而对于关系,我可以再次使用自省,找出我所有的类对象和使用mapRelationship:withMapping:在每一个
你为什么不使用Sudzc?管道代码是自动生成的,你只需要提出请求并处理它。它也会创建所有相关的对象 – doNotCheckMyBlog
我已经尝试过Sudzc,并且为我的wsdl生成了一些代码。我听说它适用于很多人,但在我的情况下它并没有! – pshah
为什么没有?任何特定的错误?正在使用第三方wsdl?还是你自己的? – doNotCheckMyBlog