首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用从WSDL2OBJC生成的代码

如何使用从WSDL2OBJC生成的代码
EN

Stack Overflow用户
提问于 2011-06-30 19:21:12
回答 1查看 4.3K关注 0票数 1

大家好,我是iphone开发的新手,从一些示例应用程序开始。

在示例应用程序中,我使用的是WebServices..我阅读了本教程http://code.google.com/p/wsdl2objc/wiki/UsageInstructions并了解了WebServices..

但是这个教程太短了,所以任何人都可以建议类似的教程或例子,这样tat就更清楚了……

谢谢你

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-07-05 15:38:24

这一切都取决于您的web服务类名等,因为wsdl2objc构成了许多NSObjects和基于此的方法,但是,如果您使用的是SOAP1.2绑定,并且您的web服务名为“SimpleService”,下面的代码将调用一个名为“MobileTestService”的web方法,并从生成的xml中返回整数值。

代码语言:javascript
复制
-(NSString *)returnThatStringFromWebServiceResult {


SimpleServiceSoap12Binding * binding = [SimpleService SimpleServiceSoap12Binding];
binding.logXMLInOut = YES; // shows all in the console log.
SimpleService_concat * testParams = [[SimpleService_concat new]autorelease];
testParams.s1 = someTextField.text; // parameters all become properties of this testParams object
testParams.s2 = anotherTextField.text;
SimpleServiceSoap12BindingResponse * response= [binding SimpleService_concatUsingParameters:testParams];
[response self]; // removes compile error

NSArray * responseBodyParts = response.bodyParts;
NSError * responseError = response.error;

if (responseError!=NULL) {
    return @"";  // if error from ws use [responeError code]; for http err code


}

for (id bodyPart in responseBodyParts)
{
    if ([bodyPart isKindOfClass:[SimpleService_concat_Response class]]) 
    {
        SimpleService_concatResponse* body = (SimpleService_concatResponse*) bodyPart;
        return body.SimpleService_concatResult; // if you are returning a string from your WS then this value will be a string, 

    }

}
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6533920

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档