2011-06-19 41 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 「(零)」