2013-03-20 19 views
1


WSDL.exe 도구를 사용하여 동적 웹 참조를 업데이트하는 데 문제가 있습니다.명령 줄 (wsdl 도구)을 통해 동적 웹 참조 업데이트

VS에서 "웹 참조 업데이트"를 사용하면 모든 것이 예상대로 작동합니다. 다음은 생성 된 코드 (Reference.cs 파일의 일부) :

public MyService() { 
     this.Url = global::ServerReference.Properties.Settings.Default.ServerReference_Reference_MyService; 
     if ((this.IsLocalFileSystemWebService(this.Url) == true)) { 
      this.UseDefaultCredentials = true; 
      this.useDefaultCredentialsSetExplicitly = false; 
     } 
     else { 
      this.useDefaultCredentialsSetExplicitly = true; 
     } 
    } 

는 그때 때문에 설정 파일에 저장되고 응용 프로그램 속성에서 필요한 정보를 얻고 응용 프로그램을 재 구축없이 변경 될 수 있습니다.

그러나 나는 다음과 같은 명령을 사용할 때 :

.\tools\wsdl.exe /l:cs /n:ServerReference /o".\ServerReference\Web References\Reference\Reference.cs" http://localhost:52956/MyService/MyService.asmx 

이 Reference.cs 파일에 고정 된 URL 주소로 작성됩니다.

아무도 내가 동일한 것을 달성하기 위해 내 명령을 변경해야한다는 것을 알고 있습니까? Reference.cs Visual Studio 에서처럼 파일이 있습니까?

답변

1

wsdl.exe를 사용하여 동일한 코드를 생성 할 수 있다고 생각하지 않습니다. 그러나 달성하려는 주요 작업이 app.config에서 서비스 주소를 가져 오는 코드를 생성하는 경우 wsdl.exe에 "/ appsettingurlkey"스위치를 사용할 수 있습니다.

이 같은 것거야 코드 : 수정해야하므로

public WebService1() { 
    string urlSetting = System.Configuration.ConfigurationManager.AppSettings["ConfigKeyForServiceUrl"]; 
    if ((urlSetting != null)) { 
     this.Url = urlSetting; 
    } 
    else { 
     this.Url = "http://localhost:65304/WebService1.asmx"; 
    } 
} 

이주의는이 설정 클래스를 통해하지 'applicationSettings'에서 'appSettings는'에서 읽는 당신의 app.config. 그리고 'UseDefaultCredentials'항목도 포함되어 있지 않습니다.