问题描述
在 WSDL2ObjC 文档中有如下示例代码,但在我生成的代码中,我找不到任何与myOperationUsingParameters"等效的类、方法或属性那是什么,我在哪里可以找到它?我也不知道myOperation"和ns1"是什么.
In the WSDL2ObjC documentation there is a sample code like below, but in my generated code I couldnt find any class, method or property equavilant to "myOperationUsingParameters" what is that and where can I find it? I don't know also what "myOperation" and what "ns1" is.
我是新手,所以在Objective C中,当我以某种方式更改变量的大写并将它们与一些关键字连接时,可能有什么意义?
I'm newbie, so in Objective C maybe there is a meaning when I change the capitals of variables in a certain way and concatenate them with some keywords?
例如:ns1_MyOperationRequest -- myOperationUsingParameters
for instance: ns1_MyOperationRequest -- myOperationUsingParameters
tnx
#import "MyWebService.h"
MyWebServiceBinding *binding = [MyWebService MyWebServiceBinding];
binding.logXMLInOut = YES;
ns1_MyOperationRequest *request = [[ns1_MyOperationRequest new] autorelease];
request.attribute = @"attributeValue";
request.element = [[ns1_MyElement new] autorelease];
request.element.value = @"elementValue"];
MyWebServiceBindingResponse *response = [binding myOperationUsingParameters:request];
推荐答案
这一切都取决于您的 Web 服务类名称等,因为 wsdl2objc 构成了许多基于此的 NSObject 和方法,但是,这表明您使用的是 soap 1.2 绑定并且您的 Web 服务被称为SimpleService",下面将调用一个名为MobileTestService"的 Web 方法并从生成的 xml 返回整数值.
All depends on your web service class name etc as wsdl2objc makes up alot of your NSObjects and methods based upon this, however, suggesting that you are using soap 1.2 bindings and your web service was called 'SimpleService', the following would call a web method named 'MobileTestService and return back the integer value from the xml generated.
-(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,
}
}
这篇关于需要有关 Objective-C 代码的帮助(生成的 WSDL2ObjC)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!