需要有关从 wsdl2objc Web 服务生成的 Objective-C 代码的帮助

发布于 2024-11-19 15:43:25 字数 1380 浏览 1 评论 0原文

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

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

由于我是 iPhone 开发新手,生成的代码包含许多方法,我很困惑要使用哪个类。我有一个编写的代码可以正确编译,但仍然无法执行。我哪里错了?下面的代码需要做哪些修改?

@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 生成的代码吗?

I am new to iPhone development. I am trying out to generate a proxy server at a client side using a wsdl2objc web service. I went through this tutorial and am doing a sample application using this tutorial.

Actually I have two strings s1 and s2 I need to concatenate the two strings and display the result on a textfield using a button. I have generated code out of the wsdl2objc file. The name of the generated class is SimpleService.

As I am new to iphone development, the generated code contains many methods where I am confused which class to be used. I have a written code which compiles correctly but still its not executing. Where I am going wrong? What corrections need to be done in the following code?

@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;
        }
    }    
}

u wan me to provide wsdl2objc generated code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风吹短裙飘 2024-11-26 15:43:25

我根本不知道 wsdl2objc 。
然而,读完代码后,在我看来,核心是基于这两行:

field.text = body.s1;
field.text = body.s2;

正如你的解释是你想连接两个字符串并在字段中显示结果,你应该尝试将上面的两行替换为

field.text = [NSString stringWithFormat:@"%@%@", body.s1, body.s2];

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

希望这有帮助。

I don't know about wsdl2objc at all.
However, after reading the code, it seems to me the heart is based on these two lines :

field.text = body.s1;
field.text = body.s2;

As your explanation is you want to concatenate two strings and display the result in the field, you should try replacing the two lines above, with :

field.text = [NSString stringWithFormat:@"%@%@", body.s1, body.s2];

This concatenates the two strings and assign the result to the text property of field.

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文