다음을 통해 공유


WebChannelFactory<TChannel> 생성자

정의

WebChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

오버로드

WebChannelFactory<TChannel>()

WebChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

WebChannelFactory<TChannel>(Binding)

WebChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

WebChannelFactory<TChannel>(ServiceEndpoint)

WebChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

WebChannelFactory<TChannel>(String)

WebChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

WebChannelFactory<TChannel>(Type)

WebChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

WebChannelFactory<TChannel>(Uri)

지정된 WebChannelFactory<TChannel>를 사용하여 Uri 클래스의 새 인스턴스를 초기화합니다.

WebChannelFactory<TChannel>(Binding, Uri)

지정된 바인딩 및 WebChannelFactory<TChannel>를 사용하여 Uri 클래스의 새 인스턴스를 초기화합니다.

WebChannelFactory<TChannel>(String, Uri)

지정된 엔드포인트 구성 및 WebChannelFactory<TChannel>를 사용하여 Uri 클래스의 새 인스턴스를 초기화합니다.

WebChannelFactory<TChannel>()

WebChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

public:
 WebChannelFactory();
public WebChannelFactory ();
Public Sub New ()

적용 대상

WebChannelFactory<TChannel>(Binding)

WebChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

public:
 WebChannelFactory(System::ServiceModel::Channels::Binding ^ binding);
public WebChannelFactory (System.ServiceModel.Channels.Binding binding);
new System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)> : System.ServiceModel.Channels.Binding -> System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)>
Public Sub New (binding As Binding)

매개 변수

binding
Binding

채널을 만들 때 사용할 바인딩입니다.

예제

다음 코드에서는 이 생성자를 사용하여 를 만들고 WebChannelFactory<TChannel> 이를 사용하여 WCF 서비스를 호출하는 방법을 보여 있습니다.

Uri baseAddress = new Uri("http://localhost:8000");
WebServiceHost host = new WebServiceHost(typeof(Service), baseAddress);
try
{
    host.Open();
    WebHttpBinding binding = new WebHttpBinding();
    WebChannelFactory<IService> cf = new WebChannelFactory<IService>(binding);
    cf.Endpoint.Address = new EndpointAddress("http://localhost:8000");
    IService channel = cf.CreateChannel();
    string s;

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ");
    s = channel.EchoWithGet("Hello, world");
    Console.WriteLine("   Output: {0}", s);
}
catch (CommunicationException ex)
{
    Console.WriteLine("An exception occurred: " + ex.Message);
}
Dim baseAddress As New Uri("http://localhost:8000")
Dim host As New WebServiceHost(GetType(Service), baseAddress)
Try
    host.Open()
    Dim binding As New WebHttpBinding()
    Dim cf As New WebChannelFactory(Of IService)(binding)
    cf.Endpoint.Address = New EndpointAddress("http://localhost:8000")
    Dim channel As IService = cf.CreateChannel()
    Dim s As String

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ")
    s = channel.EchoWithGet("Hello, world")
    Console.WriteLine("   Output:  0}", s)
Catch ex As CommunicationException
    Console.WriteLine("An exception occurred: " + ex.Message)
End Try

적용 대상

WebChannelFactory<TChannel>(ServiceEndpoint)

WebChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

public:
 WebChannelFactory(System::ServiceModel::Description::ServiceEndpoint ^ endpoint);
public WebChannelFactory (System.ServiceModel.Description.ServiceEndpoint endpoint);
new System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)> : System.ServiceModel.Description.ServiceEndpoint -> System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)>
Public Sub New (endpoint As ServiceEndpoint)

매개 변수

endpoint
ServiceEndpoint

채널을 만들 때 사용할 엔드포인트입니다.

예제

다음 코드에서는 이 생성자를 사용하여 를 만들고 WebChannelFactory<TChannel> 이를 사용하여 WCF 서비스를 호출하는 방법을 보여 있습니다.

Uri baseAddress = new Uri("http://localhost:8000");
WebServiceHost host = new WebServiceHost(typeof(Service), baseAddress);
try
{
    host.Open();

    WebHttpBinding binding = new WebHttpBinding();
    ContractDescription desc = ContractDescription.GetContract(typeof(IService));
    EndpointAddress endpointAddress = new EndpointAddress("http://localhost:8000");
    ServiceEndpoint endpoint = new ServiceEndpoint(desc, binding, endpointAddress);

    WebChannelFactory<IService> cf = new WebChannelFactory<IService>(endpoint);
    IService channel = cf.CreateChannel();
    string s;

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ");
    s = channel.EchoWithGet("Hello, world");
    Console.WriteLine("   Output: {0}", s);
}
catch (CommunicationException ex)
{
    Console.WriteLine("An exception occurred: " + ex.Message);
}
Dim baseAddress As New Uri("http://localhost:8000")
Dim host As New WebServiceHost(GetType(Service), baseAddress)
Try
    host.Open()

    Dim binding As New WebHttpBinding()
    Dim desc As ContractDescription = ContractDescription.GetContract(GetType(IService))
    Dim endpointAddress As New EndpointAddress("http://localhost:8000")
    Dim endpoint As New ServiceEndpoint(desc, binding, endpointAddress)

    Dim cf As New WebChannelFactory(Of IService)(endpoint)
    Dim channel As IService = cf.CreateChannel()
    Dim s As String

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ")
    s = channel.EchoWithGet("Hello, world")
    Console.WriteLine("   Output:  0}", s)
Catch ex As CommunicationException
    Console.WriteLine("An exception occurred: " + ex.Message)
End Try

적용 대상

WebChannelFactory<TChannel>(String)

WebChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

public:
 WebChannelFactory(System::String ^ endpointConfigurationName);
public WebChannelFactory (string endpointConfigurationName);
new System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)> : string -> System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)>
Public Sub New (endpointConfigurationName As String)

매개 변수

endpointConfigurationName
String

채널이 구성되는 애플리케이션 구성 파일에 있는 이름입니다.

예제

다음 코드에서는 이 생성자를 사용하여 instance 만들고 WebChannelFactory<TChannel> 이를 사용하여 WCF 서비스를 호출하는 방법을 보여줍니다.

Uri baseAddress = new Uri("http://localhost:8000");
WebServiceHost host = new WebServiceHost(typeof(Service), baseAddress);
try
{
    host.Open();

    // The endpoint name passed to the constructor must match an endpoint element
    // in the application configuration file
    WebChannelFactory<IService> cf = new WebChannelFactory<IService>("MyEndpoint");
    IService channel = cf.CreateChannel();
    string s;

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ");
    s = channel.EchoWithGet("Hello, world");
    Console.WriteLine("   Output: {0}", s);
}
catch (CommunicationException ex)
{
    Console.WriteLine("An exception occurred: " + ex.Message);
}
Dim baseAddress As New Uri("http://localhost:8000")
Dim host As New WebServiceHost(GetType(Service), baseAddress)
Try
    host.Open()

    ' The endpoint name passed to the constructor must match an endpoint element
    ' in the application configuration file
    Dim cf As New WebChannelFactory(Of IService)("MyEndpoint")
    Dim channel As IService = cf.CreateChannel()
    Dim s As String

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ")
    s = channel.EchoWithGet("Hello, world")
    Console.WriteLine("   Output:  0}", s)
Catch ex As CommunicationException
    Console.WriteLine("An exception occurred: " + ex.Message)
End Try

설명

endpointConfigurationName 매개 변수는 애플리케이션 구성 파일에 있는 name 요소의 <endpoint> 특성과 동일한 값으로 설정되어야 합니다.

적용 대상

WebChannelFactory<TChannel>(Type)

WebChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

public:
 WebChannelFactory(Type ^ channelType);
public WebChannelFactory (Type channelType);
new System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)> : Type -> System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)>
Public Sub New (channelType As Type)

매개 변수

channelType
Type

사용할 채널 형식입니다.

설명

형식 매개 변수에 전달된 형식은 인터페이스여야 합니다.

적용 대상

WebChannelFactory<TChannel>(Uri)

지정된 WebChannelFactory<TChannel>를 사용하여 Uri 클래스의 새 인스턴스를 초기화합니다.

public:
 WebChannelFactory(Uri ^ remoteAddress);
public WebChannelFactory (Uri remoteAddress);
new System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)> : Uri -> System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)>
Public Sub New (remoteAddress As Uri)

매개 변수

remoteAddress
Uri

호출되는 웹 서비스의 URI입니다.

예제

다음 코드에서는 이 생성자를 사용하여 instance 만들고 WebChannelFactory<TChannel> 서비스를 호출하는 방법을 보여줍니다.

Uri baseAddress = new Uri("http://localhost:8000");
WebServiceHost host = new WebServiceHost(typeof(Service), baseAddress);
try
{
    host.Open();

    WebChannelFactory<IService> cf = new WebChannelFactory<IService>(new Uri("http://localhost:8000"));
    IService channel = cf.CreateChannel();
    string s;

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ");
    s = channel.EchoWithGet("Hello, world");
    Console.WriteLine("   Output: {0}", s);
}
catch (CommunicationException ex)
{
    Console.WriteLine("An exception occurred: " + ex.Message);
}
Dim baseAddress As New Uri("http://localhost:8000")
Dim host As New WebServiceHost(GetType(Service), baseAddress)
Try
    host.Open()

    Dim cf As New WebChannelFactory(Of IService)(New Uri("http://localhost:8000"))
    Dim channel As IService = cf.CreateChannel()
    Dim s As String

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ")
    s = channel.EchoWithGet("Hello, world")
    Console.WriteLine("   Output:  0}", s)
Catch ex As CommunicationException
    Console.WriteLine("An exception occurred: " + ex.Message)
End Try

적용 대상

WebChannelFactory<TChannel>(Binding, Uri)

지정된 바인딩 및 WebChannelFactory<TChannel>를 사용하여 Uri 클래스의 새 인스턴스를 초기화합니다.

public:
 WebChannelFactory(System::ServiceModel::Channels::Binding ^ binding, Uri ^ remoteAddress);
public WebChannelFactory (System.ServiceModel.Channels.Binding binding, Uri remoteAddress);
new System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)> : System.ServiceModel.Channels.Binding * Uri -> System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)>
Public Sub New (binding As Binding, remoteAddress As Uri)

매개 변수

binding
Binding

사용할 바인딩입니다.

remoteAddress
Uri

호출되는 웹 서비스의 URI입니다.

예제

다음 코드에서는 이 생성자를 사용하여 instance 만들고 WebChannelFactory<TChannel> 서비스를 호출하는 방법을 보여줍니다.

Uri baseAddress = new Uri("http://localhost:8000");
WebServiceHost host = new WebServiceHost(typeof(Service), baseAddress);
try
{
    host.Open();

    WebHttpBinding binding = new WebHttpBinding();
    WebChannelFactory<IService> cf = new WebChannelFactory<IService>(binding, new Uri("http://localhost:8000"));
    IService channel = cf.CreateChannel();
    string s;

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ");
    s = channel.EchoWithGet("Hello, world");
    Console.WriteLine("   Output: {0}", s);
}
catch (CommunicationException ex)
{
    Console.WriteLine("An exception occurred: " + ex.Message);
}
Dim baseAddress As New Uri("http://localhost:8000")
Dim host As New WebServiceHost(GetType(Service), baseAddress)
Try
    host.Open()

    Dim binding As New WebHttpBinding()
    Dim cf As New WebChannelFactory(Of IService)(binding, New Uri("http://localhost:8000"))
    Dim channel As IService = cf.CreateChannel()
    Dim s As String

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ")
    s = channel.EchoWithGet("Hello, world")
    Console.WriteLine("   Output:  0}", s)
Catch ex As CommunicationException
    Console.WriteLine("An exception occurred: " + ex.Message)
End Try

적용 대상

WebChannelFactory<TChannel>(String, Uri)

지정된 엔드포인트 구성 및 WebChannelFactory<TChannel>를 사용하여 Uri 클래스의 새 인스턴스를 초기화합니다.

public:
 WebChannelFactory(System::String ^ endpointConfigurationName, Uri ^ remoteAddress);
public WebChannelFactory (string endpointConfigurationName, Uri remoteAddress);
new System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)> : string * Uri -> System.ServiceModel.Web.WebChannelFactory<'Channel (requires 'Channel : null)>
Public Sub New (endpointConfigurationName As String, remoteAddress As Uri)

매개 변수

endpointConfigurationName
String

채널이 구성되는 애플리케이션 구성 파일에 있는 이름입니다.

remoteAddress
Uri

호출되는 웹 서비스의 URI입니다.

예제

다음 코드에서는 이 생성자를 사용하여 instance 만들고 WebChannelFactory<TChannel> 서비스를 호출하는 방법을 보여줍니다.

Uri baseAddress = new Uri("http://localhost:8000");
WebServiceHost host = new WebServiceHost(typeof(Service), baseAddress);
try
{
    host.Open();

    // The endpoint name passed to the constructor must match an endpoint element
    // in the application configuration file
    WebChannelFactory<IService> cf = new WebChannelFactory<IService>("MyEndpoint", new Uri("http://localhost:8000"));
    IService channel = cf.CreateChannel();
    string s;

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ");
    s = channel.EchoWithGet("Hello, world");
    Console.WriteLine("   Output: {0}", s);
}
catch (CommunicationException ex)
{
    Console.WriteLine("An exception occurred: " + ex.Message);
}
Dim baseAddress As New Uri("http://localhost:8000")
Dim host As New WebServiceHost(GetType(Service), baseAddress)
Try
    host.Open()

    ' The endpoint name passed to the constructor must match an endpoint element
    ' in the application configuration file
    Dim cf As New WebChannelFactory(Of IService)("MyEndpoint", New Uri("http://localhost:8000"))
    Dim channel As IService = cf.CreateChannel()
    Dim s As String

    Console.WriteLine("Calling EchoWithGet via HTTP GET: ")
    s = channel.EchoWithGet("Hello, world")
    Console.WriteLine("   Output:  0}", s)
Catch ex As CommunicationException
    Console.WriteLine("An exception occurred: " + ex.Message)
End Try

설명

endpointConfigurationName 매개 변수는 애플리케이션 구성 파일에 있는 name 요소의 <endpoint> 특성과 동일한 값으로 설정되어야 합니다.

적용 대상