大家好,我是iphone开发的新手,从一些示例应用程序开始。
在示例应用程序中,我使用的是WebServices..我阅读了本教程http://code.google.com/p/wsdl2objc/wiki/UsageInstructions并了解了WebServices..
但是这个教程太短了,所以任何人都可以建议类似的教程或例子,这样tat就更清楚了……
谢谢你
发布于 2011-07-05 15:38:24
这一切都取决于您的web服务类名等,因为wsdl2objc构成了许多NSObjects和基于此的方法,但是,如果您使用的是SOAP1.2绑定,并且您的web服务名为“SimpleService”,下面的代码将调用一个名为“MobileTestService”的web方法,并从生成的xml中返回整数值。
-(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,
}
}
}https://stackoverflow.com/questions/6533920
复制相似问题