2011-06-19 45 views
0

在WSDL2ObjC文档中有一个像下面这样的示例代码,但是在我生成的代码中,我无法找到与“myOperationUsingParameters”等同的任何类,方法或属性,那是什么和我在哪里可以找到它?我也不知道“myOperation”和“ns1”是什么。需要关于Objective-C代码的帮助(WSDL2ObjC生成)

我是新手,所以在Objective C中,当我以某种方式更改变量的大写字母并将它们与某些关键字连接起来时,这可能有意义吗?

例如: 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]; 

回答

2

一切都取决于你的Web服务类的名称等作为wsdl2objc弥补很多你NSObjects并基于此方法,但是,这您使用的是soap 1.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, 

    } 

} 
+0

感谢现在最近我决定使用简单的HTTP POST和我可以收到毫无问题地发送xml,你认为我应该使用这样的库有一个很好的理由吗?考虑到它很复杂,没有很好的记录?我将解析我的XML编辑并将其发回。 – Spring

+0

@xDeveloper你的意思是你使用http进行连接,然后再解析xml,那你到底想做什么? – Abhilash

+0

是的,这就是我做什么,我需要什么..我需要编辑xml并将其发回到Web服务,但想知道为什么所有使用这种库的人,我错过了什么? – Spring

0

在WSDL2ObjC获取数据= <>和响应是没有。
代码:

VKQWare_Binding * binding = [[VKQWare_Binding alloc] init]; 
VKQRequestResultHandler *reqResultHandler = [[VKQRequestResultHandler alloc]init]; 
binding.EnableLogging = YES; 
reqResultHandler.EnableLogging = YES; 

NSMutableURLRequest *mutableURLRequest = [binding createPasswordRequest:@"userName" p_txtPassword:@"Password" p_codLocationCode:@"xxx" __request:reqResultHandler]; 
[reqResultHandler prepareRequest:mutableURLRequest]; 
[reqResultHandler sendImplementation:mutableURLRequest]; 

OutputHeader:(空) OutputBody:(空) OutputFault:错误域=代码= 0 “(零)”