최근에 WCF로 작업하기 시작했습니다. 문제 해결 방법이 하나도 없습니다. 서비스 호스트를 사용하여 WCF 서비스를 시작하지만 브라우저에서 URI를 사용하면 서비스 계약이 표시되지 않고 ChannelFactory를 사용하여 URI에 연결하려고하면 예외가 발생합니다.WCF 오류 - 서비스 끝점을 얻을 수 없습니다.
Visual Studio 2017에서 프로젝트를 만들었고 config 파일에 아무 것도하지 않았으므로 기본 주소를 변경했습니다. 서비스 인터페이스와 구현 모두 루트 프로젝트 "폴더"에 있으며 방화벽과 심지어 내 바이러스 백신을 비활성화하려고 시도했지만 아무 것도 작동하지 않는 것 같습니다.
의 App.config :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="TaskExecutor.Exec">
<endpoint address="" binding="basicHttpBinding" contract="TaskExecutor.IExec">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8001/TaskExecutor/Exec/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
서비스 인터페이스 :
namespace TaskExecutor
{
[ServiceContract]
public interface IExec
{
[OperationContract]
void DoWork();
}
}
서비스 구현 :
namespace TaskExecutor
{
public class Exec : IExec
{
public void DoWork()
{
Console.WriteLine("Doing work.");
}
}
}
프로그램 실행 서비스 :
using (ServiceHost host = new ServiceHost(typeof(Exec)))
{
host.Open();
Console.WriteLine("exec service started at {0}", host.BaseAddresses[0]);
}
Console.WriteLine("Press any key to end...");
Console.ReadLine();
,
프로그램이 메시지를 표시 시작 후 :
EndpointAddress endpoint = new EndpointAddress("http://localhost:8001/TaskExecutor/Exec/");
BasicHttpBinding binding = new BasicHttpBinding();
ChannelFactory<IExec> channelFactory = new ChannelFactory<IExec>(binding, endpoint);
IExec proxy = channelFactory.CreateChannel();
proxy.DoWork();
그리고 그것은 예외를 제공합니다 :
exec service started at http://localhost:8001/TaskExecutor/Exec/
Press any key to end...
서비스 클라이언트 코드는 다음과
System.ServiceModel.EndpointNotFoundException occurred
HResult=0x80131501
Message=There was no endpoint listening at http://localhost:8001/TaskExecutor/Exec/ that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
Inner Exception 1:
WebException: Unable to connect to the remote server
Inner Exception 2:
SocketException: No connection could be made because the target machine actively refused it
내가 심각하게 돈
를 ' 무엇을해야하는지 알며, 어떤 도움도 훌륭합니다.
대단히 감사합니다!
는 WCF에 단계 튜토리얼에 의해 간단한 단계에서이 사이트로 이동 - – MethodMan
덕분에 입력 https://www.tutorialspoint.com/wcf/wcf_creating_service.htm, 하지만 그다지 도움이되지 못했습니다. 저는 거의 그 튜토리얼에있는 것과 똑같은 일을했습니다. – gqmartins