this example을 기반으로 WCF 콜백 서비스에 대한 자체 호스팅을 수행하려고합니다.콜백 WCF 서비스를 만들 때 EndpointNotFoundException이 발생했습니다.
서비스 :
static void Main(string[] args)
{
using (ServiceHost host = new ServiceHost(typeof(Message), new Uri("http://localhost:8000/HelloWCF")))
{
// Set up a service endpoint [Contract, Binding, Address]
host.AddServiceEndpoint(typeof(IMessage), new WSDualHttpBinding() { ClientBaseAddress = new Uri("http://locahost:8001/HelloWCF") }, "HelloWCF");
// Enable metadata exchange
ServiceMetadataBehavior smb = new ServiceMetadataBehavior() {HttpGetEnabled =true };
host.Description.Behaviors.Add(smb);
host.Open();
Console.WriteLine("Ready...");
Console.ReadLine();
}
}
클라이언트 :
의 app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsDualHttpBinding >
<binding name="WSDualHttpBinding_IMessage" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" clientBaseAddress="http://locahost:8001/HelloWCF">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8000/HelloWCF/HelloWCF" binding="wsDualHttpBinding"
bindingConfiguration="WSDualHttpBinding_IMessage" contract="CallbackService.IMessage"
name="WSDualHttpBinding_IMessage" >
<identity>
<userPrincipalName value="badasscomputing\menkaur" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
C# 코드 :
[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]
class Sender : IMessageCallback, IDisposable
{
private MessageClient messageClient;
public void Go()
{
InstanceContext context = new InstanceContext(this);
messageClient = new MessageClient(context, "WSDualHttpBinding_IMessage");
for (int i = 0; i < 5; i++)
{
string message = string.Format("message #{0}", i);
Console.WriteLine(">>> Sending " + message);
messageClient.AddMessage(message);
}
}
public void OnMessageAdded(string message, DateTime timestamp)
{
}
public void Dispose()
{
messageClient.Close();
}
}
[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]
class Listener : IMessageCallback, IDisposable
{
private MessageClient messageClient;
public void Open()
{
InstanceContext context = new InstanceContext(this);
messageClient = new MessageClient(context, "WSDualHttpBinding_IMessage");
messageClient.Subscribe();
}
public void OnMessageAdded(string message, DateTime timestamp)
{
Console.WriteLine("<<< Recieved {0} with a timestamp of {1}", message, timestamp);
}
public void Dispose()
{
messageClient.Unsubscribe();
messageClient.Close();
}
}
static void Main(string[] args)
{
Listener l = new Listener();
l.Open();
Sender s = new Sender();
s.Go();
}
여기
는 호스팅 코드입니다
서버가 올바르게 시작됩니다. 클라이언트를 실행할 때 , 그것은 다음과 같은 예외로 서버 함수를 호출 할 때 충돌 :
EndpointNotFoundException:There was no endpoint listening at http://localhost:8000/HelloWCF/HelloWCF that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
내부 예외는 : 원격 서버에 연결할 수 없습니다.
내가 성공적으로의 원인이 될 수있는 어떤 콜백 함수
없이 유사한 응용 프로그램을 시험이 때문에 방화벽이 아닌?
업데이트]
전체 소스는 여기에서 다운로드 할 수 있습니다 http://iathao.com/tmp/fullSource.zip
* badasscomputing * 내가 http로 클라이언트 측의 엔드 포인트를 설정하면 –