Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 12862
글쓴 사람
임동찬 (dngchn.im at samsung.com)
홈페이지
첨부 파일
 

안녕하세요.
오랫만에 또 질문 있어 찾아왔습니다.
(늦었지만 새해 복 많이 받으세요.)

WCF 클라이언트를 만드는데요.
Service Reference에 서비스 참조를 하여
자동으로 프록시 코드를 생성해서 사용하려고 합니다.

프록시에 정의된 서비스의 클라이언트 생성자에 대해서 인데요.
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class CalculatorServiceClient : System.ServiceModel.ClientBase<Microsoft.Samples.Discovery.ServiceReference1.ICalculatorService>, Microsoft.Samples.Discovery.ServiceReference1.ICalculatorService {

        public CalculatorServiceClient(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint)
            : base(serviceEndpoint)
        {
        }
프록시에 위와 같이 생성자가 정의되고,
CalculatorServiceClient client = new CalculatorServiceClient(serviceEndpoint);
위와 같이 프록시 클라이언트를 생성해서 사용하고자 합니다.

그런데 프록시 코드를 생성해보면,
public CalculatorServiceClient() {
        }
        
        public CalculatorServiceClient(string endpointConfigurationName) :
                base(endpointConfigurationName) {
        }
        
        public CalculatorServiceClient(string endpointConfigurationName, string remoteAddress) :
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public CalculatorServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public CalculatorServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
                base(binding, remoteAddress) {
        }

위와 같이 생성자의 파라미터가 endpoint가 아닌 string 타입의 endpointconfigurationname으로 만들어 지네요.

물론 자동 생성된 이후에 프록시 생성자를 System.ServiceModel.Description.ServiceEndpoint 타입으로 수동 편집 하면 되겠지만,
서비스 업데이트 할때마다 매번 해줘야 하게 되니, 뭔가 방법이 있을 듯 한데, 어떻게 하면 될까요?









[최초 등록일: ]
[최종 수정일: 2/11/2011]


비밀번호

댓글 작성자
 



2011-02-12 01시05분
그래서 ^^ partial 예약어가 빛을 발합니다. 위의 프록시 클래스가 생성되는 프로젝트에 임의의 cs 파일을 추가하고, 거기에

partial class CalculatorServiceClient
{
  public CalculatorServiceClient(System.ServiceModel.Description.ServiceEndpoint ...);
}
라고 코드를 넣어주시면 됩니다. 그럼, 프록시 업데이트는 그 나름대로 계속 진행될 것이고 위에 추가된 파일은 변경되지 않고 남게 되므로 빌드시 에 2개의 소스 코드가 합쳐져서 결과물이 나오게 됩니다. ^^
정성태

... 46  47  48  49  50  51  52  53  54  [55]  56  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
1279(non...6/23/201411515(글쓴이의 요청으로 삭제합니다.) [17]
1278이상식6/19/201412759.net DLL 내 자바스크립트를 수정 또는 재정의 할 수 있을까요? [3]
1277김솔지6/18/201410452silverlight에서 datagrid, listbox질문이여 [2]
1276정우석6/16/20149955쿠키 [1]
1274김솔지6/10/201414456배포 페이지 url을 얻고 싶습니다. [8]
1272이훈모6/7/201410003정말 어려운 상황에 직면했습니다. [1]
1270Jong...6/2/201419473C#과 C++을 이용한 Image 처리. [13]
1269김아영5/29/201410176InitializeComponent 함수 호출 지연 현상 [5]
1268솔솔5/27/20149838smart client [1]
1266김솔지5/22/201411908clickonce 수정에 대해 알고싶습니다. [2]
1265이은아5/22/201415514DataGridView 헤더를 두줄이상으로 하고싶습니다. [1]파일 다운로드1
1264김인호5/18/201413095소스코드 및 예제그림 zip 파일 [1]
1263이영종5/15/201411546159페이지 오타인것 같습니다 [5]
1262(non...5/4/201412443(글쓴이의 요청으로 삭제합니다.) [10]
1261이근주5/4/201410744다시 한번 질문드릴께요. [2]
1259이근주5/1/20149796도서 오류인 것 같네요.. [1]
1258최세정4/28/201412210안녕하세요~php module 오류로 고민하다가 여기까지 왔네요..ㅜㅜ [2]
1252popo4/21/201411458바인딩 질문입니다. [2]
1251(non...4/20/201415588(글쓴이의 요청으로 삭제합니다.) [11]
1249홍용규4/17/201415566app.config 파일 관련 질문 있습니다. [2]
1246(non...3/30/201411917(글쓴이의 요청으로 삭제합니다.) [1]
1245POPO3/26/201411315Http 프로토콜 관련 질문 입니다. [1]
1244(non...3/26/201411420(글쓴이의 요청으로 삭제합니다.) [1]
1241(non...3/22/201415213(글쓴이의 요청으로 삭제합니다.) [4]
1240이석주3/21/201418108인터넷 익스플로러가 hang이 걸리는 현상 문의 [1]파일 다운로드1
1238(non...3/13/201411963(글쓴이의 요청으로 삭제합니다.) [2]
... 46  47  48  49  50  51  52  53  54  [55]  56  57  58  59  60  ...