2013-10-14 6 views
2

iOS에 대한 wsdl 파일에서 소스 코드를 생성하려고합니다. 나는 두 도구를 우연히 만났으며 지금까지는 적어도 wsclient++sudz C가 작동하는 것처럼 보입니다. 그러나 iOS 앱의 상태에 따라 동일한 soap 인터페이스를 사용하여 여러 서버에 요청을 보내야합니다. 내가 나를sudzc를 사용하여 서버 URL을 변경할 수 있습니까?

if(condition1) [SoapWebService setGlobalBaseUrl: @"http://betaserver.com"]; 
if(condition2) [SoapWebService setGlobalBaseUrl: @"http://developserver.com"]; 
if(condition3) [SoapWebService setGlobalBaseUrl: @"http://liveserver.com"]; 

같은 것을 할 수 있도록 할

MyWebService* ws = [MyWebService service]; 
// // set base url for entire application 
[SoapWebService setGlobalBaseUrl: @"http://domain.com"]; 
NSError* error = nil; 
Result* rs = [ws callMethod: p1 param2:p2 error:&error]; 

를 통해 내가 서버 URL을 설정할 수 있습니다 wsclient에 의해 생성 된 소스 코드에서

와 비슷한 보관하는 방법이 있나요 sudzc에 의해 생성 된 소스 코드?

답변

0

비누가 동일한 응답을하는 한 코드를 사용하는 데 문제가 없어야합니다. 서버 주소를 저장하는 파일이 있습니다. sudzc에서 생성 된 코드는 임의의 주소로 수정할 수 있습니다. 실제로 서버를 때리는 역동적 인 방법을 만들었습니다. 나는 이것을하기 위해 사용 된 파일과 코드를 발견 할 것이다. sudzc에 사용했던 도메인의 프로젝트를 검색 할 수 있습니다.

저는 지금 맥 앞에 있지 않지만 나중에 업데이트 할 것입니다.

UPDATE: 

좋아요, 그래서 설정 탭을 만들었고 사용자가 필요한 경우 특정 IP 주소를 입력 할 수있었습니다. 사전에 IP 주소를 저장 한 다음이 파일은 사전에서 IP 주소를 검색합니다. 내 원래 의견 중 일부를 남겨 두 코드를 추가하여 두 가지 방법을 모두 볼 수 있습니다. 혼란 스러울 경우 알려 주시면 다시 편집하겠습니다. 내 sudzc에서 생성 한 코드에서 나는이에 파일을 수정 :

/* 
wsUpdateQOH.m 
The implementation classes and methods for the wsUpdateQOH web service. 
Generated by SudzC.com 
*/ 

#import "wsUpdateQOH.h"   
#import "Soap.h" 
#import "Settings.h" 
#define URL @"http://%@/webServiceAddress/updateqoh.asmx" 




/* Implementation of the service */ 

@implementation wsUpdateQOH 

- (id) init 
{ 
    if(self = [super init]) 
    { 
     // take out hard coded address and add variable to have a dynamic IP @"http://www.site.com/webServiceAddress/updateqoh.asmx" 
     // here is the dictionary return and format of the url string 
     NSString *savedValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"serverIP"]; 
     self.serviceUrl = [[NSString alloc] initWithFormat:URL, savedValue]; 

     // uncomment for a hard coded address self.serviceUrl = @"http://%@/webServiceAddress/updateqoh.asmx"; 
     self.namespace = @"http://tempuri.org/webServiceAddress/UpdateQOH"; 
     self.headers = nil; 
     self.logging = NO; 

    } 
    return self; 

} 

- (id) initWithUsername: (NSString*) username andPassword: (NSString*) password { 
    if(self = [super initWithUsername:username andPassword:password]) { 
    } 
    return self; 
} 

+ (wsUpdateQOH*) service { 
    return [wsUpdateQOH serviceWithUsername:nil andPassword:nil]; 
} 

+ (wsUpdateQOH*) serviceWithUsername: (NSString*) username andPassword: (NSString*) password { 
    return [[[wsUpdateQOH alloc] initWithUsername:username andPassword:password] autorelease]; 
} 
// *** Below here is the soap actions *** 
내가 모든 generted 기능 SoapRequest 같은 것을 가지고 있기 때문에, 코드를보고 싶다
+0

* _request = [SoapRequest 만들 : _target 조치 : _action 서비스 : 자기의 soapAction : @ "http://server.com/xyz/GetSecurityToken"postData : _envelope deserializeTo : @ "NSString"]; 나는 마치 글로벌 서버 URL을 설정할 수있는 것처럼 보이지 않습니다./ – user2879242

+0

당신을 위해 그것을 업데이트했습니다. – iDev