WCF의 EndPoint의 메서드를 문자열로 호출하고 싶을 때 다음과 같이 사용하면된다.
protected int ServiceInt<TClient, TChannel>(string methodName, params object[] methodParameters)
where TClient : class, ICommunicationObject
where TChannel : class
{
var client = Activator.CreateInstance<TClient>();
DataSet ds = new DataSet();
BasicHttpBinding binding = new BasicHttpBinding();
//EndpointAddress endPoint = new EndpointAddress("http://localhost/WebService/WCFSample.svc");
EndpointAddress endPoint = new EndpointAddress(ServiceEndPointSearch(typeof(TChannel).FullName.Replace("Test.", "")));
ChannelFactory<TChannel> channel = new ChannelFactory<TChannel>(binding, endPoint);
TChannel wcfClient = channel.CreateChannel();
Type type = typeof(TChannel);
MethodInfo mi = type.GetMethod(methodName);
int result = (int)mi.Invoke(wcfClient, methodParameters);
((IClientChannel)wcfClient).Close();
return result;
}
'ASP.Net' 카테고리의 다른 글
세션 상태 서버에 세션 상태 요청을 할 수 없습니다. ASP.NET 상태 서비스가 시작되었으며 클라이언트 포트와 서버 포트가 같은지 확인하십시오. (4) | 2017.02.07 |
---|---|
이 요청을 처리하려면 구성에 WebResource.axd 처리기를 등록해야 합니다. (1) | 2017.02.07 |
WCF app.config에 있는 EndPoint 찾기 (0) | 2015.10.29 |
HTTP 오류 500.21 - Internal Server Error (1) | 2015.07.31 |
파일 업로드 용량 관련 정보 (0) | 2015.07.31 |
댓글