Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 17859
글쓴 사람
임동찬 (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개의 소스 코드가 합쳐져서 결과물이 나오게 됩니다. ^^
정성태

... 76  77  78  79  80  81  82  83  84  85  86  87  88  [89]  90  ...
NoWriterDateCnt.TitleFile(s)
239장강현9/14/200514950SmartClient에서의 배포 문제에 대해 [2]
238이순원9/13/200510340디버깅 할때 native 옵션껐는데두 너무 느려요.. [1]
236코디9/12/200510273[질문]런타임 보안 배포 [1]
237코디9/13/200510838    답변글 [재질문]: [질문]런타임 보안 배포 [1]파일 다운로드1
235임은선9/9/200512878스마트 클라이언트 배포시 환경파일인 app.config는 어떻게 배포 해야하나요...? [2]
234임은선9/7/200511659스마트 클라이언트 보안문제관련해서 질문이 있습니다.. [2]
233이한욱8/31/200519713가상 시리얼 포트(Virtual COM Port) 만들기 [1]
232정준명8/30/200511353[질문] HTTP 모듈/핸들러 또는 RewriteURL 관련입니다. [4]
231이진일8/30/200510467참조한 dll 들은 어떻게 배포하나요...? [1]
2303028/29/200511273[질문] 웹에서 Exchange Server 사용자 추가 [2]
229김재명8/26/200510900성태님의 홈페이지 J & J의경우 보안모듈을 어떻게 해결하셨는지 궁금합니다. [1]
227임규진8/24/200510752리소스 파일에 그림 첨가하는 방법 좀 알려 주세요. [1]
226최인호8/19/200510794스마트 클라이언트 exe 버젼 실행시 시간이 너무 오래 걸립니다. [1]
225코디8/17/200510977[질문]닷넷프레임워크 설치여부 [1]
224박준현8/17/200510543[질문]중첩 그리드라고 해야 할까요? [1]
223매커7/28/20059962강좌 잘 읽었습니다. [1]
222김지영7/27/200511444C#에서 oledb 사용하다가 에러 [2]
221박민우7/26/200512008스마트클라이언트에서의 DB접속 [1]
220테드7/22/200510929스마트 클라이언트에서 원치 않는 패킷 송수신 문제... [3]
219김종욱7/21/200511418안녕하세요... 툴밴드 콤보 박스에 대해.. [1]
2187/21/200510051스마트 클라이언트에 대한 질문 입니다. [1]파일 다운로드1
217왕초보7/21/200510668마소강좌의 AxForSmartClient 를 실행시키고 싶은데요... [1]
215궁금증6/23/200510156도대체 이게 무슨 에러 일까요... [1]
213궁금이6/18/200511848Winform 형태의 NTD에서 사용자 로그인 성공 여부 정보 유지하는 방법 [1]
212궁금이6/16/20059849ActiveX 컨트롤이 NTD에 이상이 없는지요? [1]
211류성태6/15/200510391smart client에 관하여.... [1]
... 76  77  78  79  80  81  82  83  84  85  86  87  88  [89]  90  ...