首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >需要有关从wsdl2objc webservice生成的Objective-C代码的帮助

需要有关从wsdl2objc webservice生成的Objective-C代码的帮助
EN

Stack Overflow用户
提问于 2011-07-11 14:31:37
回答 1查看 660关注 0票数 0

我是iPhone开发的新手。我正在尝试使用wsdl2objc web服务在客户端生成代理服务器。我浏览了this tutorial,并使用本教程制作了一个示例应用程序。

实际上,我有两个字符串s1和s2,我需要将这两个字符串连接起来,并使用一个按钮在文本字段中显示结果。我已经从wsdl2objc文件中生成了代码。生成的类的名称是SimpleService

我有一个正确编译的书面代码,但它仍然没有执行。我哪里错了?在以下代码中需要做哪些更正?

代码语言:javascript
复制
@implementation WsdlViewController
@synthesize field;
-(IBAction)buttonpressed:(id)sender
{
    SimpleServiceSOAP *binding = [SimpleService SimpleServiceSOAP];
    binding.logXMLInOut = YES;
    SimpleService_concat *testParams = [[SimpleService_concat new]autorelease];
    testParams.s1 = field.text;   // parameters all become properties of this testParams object
    testParams.s2 = field.text;          
    SimpleServiceSOAPResponse * response = [binding   concatUsingParameters: testParams];  
                                   [response self];
    NSArray * responseBodyParts = response.bodyParts;
    NSError *responseError = response.error;
    for (id bodypart in responseBodyParts)
    {
        if ([bodypart  isKindOfClass:[SimpleService_concat class]])
        {
           SimpleService_concat * body = (SimpleService_concat *)bodypart; 
            field.text = body.s1;
            field.text = body.s2;
        }
    }    
}

你想让我提供wsdl2objc生成的代码吗?

EN

回答 1

Stack Overflow用户

发布于 2011-07-13 17:50:46

我对wsdl2objc一无所知。然而,在读完代码后,在我看来,它的核心是基于这两行:

代码语言:javascript
复制
field.text = body.s1;
field.text = body.s2;

由于您的解释是希望连接两个字符串并在字段中显示结果,因此您应该尝试将上面的两行替换为:

代码语言:javascript
复制
field.text = [NSString stringWithFormat:@"%@%@", body.s1, body.s2];

这将连接这两个字符串,并将结果分配给fieldtext属性。

希望这能有所帮助。

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

https://stackoverflow.com/questions/6646512

复制
相关文章

相似问题

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