我是iPhone开发的新手。我正在尝试使用wsdl2objc web服务在客户端生成代理服务器。我浏览了this tutorial,并使用本教程制作了一个示例应用程序。
实际上,我有两个字符串s1和s2,我需要将这两个字符串连接起来,并使用一个按钮在文本字段中显示结果。我已经从wsdl2objc文件中生成了代码。生成的类的名称是SimpleService。
我有一个正确编译的书面代码,但它仍然没有执行。我哪里错了?在以下代码中需要做哪些更正?
@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生成的代码吗?
发布于 2011-07-13 17:50:46
我对wsdl2objc一无所知。然而,在读完代码后,在我看来,它的核心是基于这两行:
field.text = body.s1;
field.text = body.s2;由于您的解释是希望连接两个字符串并在字段中显示结果,因此您应该尝试将上面的两行替换为:
field.text = [NSString stringWithFormat:@"%@%@", body.s1, body.s2];这将连接这两个字符串,并将结果分配给field的text属性。
希望这能有所帮助。
https://stackoverflow.com/questions/6646512
复制相似问题