나는이 오류에 대해 몇 시간 동안 검색 한 결과 Google에있는 모든 것을 거의 테스트했습니다.WCF 메타 데이터에는 해결할 수없는 참조가 포함되어 있습니다.
C#에서 TCP, .NET4 및 VS2010을 사용하여 서비스에 액세스하려고합니다.
namespace WcfService_using_callbacks_via_tcp
{
[ServiceContract(CallbackContract = typeof(ICallback), SessionMode = SessionMode.Required)]
public interface IService1
{
[OperationContract]
string Test(int value);
}
public interface ICallback
{
[OperationContract(IsOneWay = true)]
void ServerToClient(string sms);
}
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
public class Service1 : IService1
{
public string Test(int value)
{
ICallback the_callback = OperationContext.Current.GetCallbackChannel<ICallback>();
the_callback.ServerToClient("Callback from server, waiting 1s to return value.");
Thread.Sleep(1000);
return string.Format("You entered: {0}", value);
}
}
}
이의 Web.config와 :
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="WcfService_using_callbacks_via_tcp.Service1" behaviorConfiguration="Behaviour_Service1">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:5050/Service1" />
</baseAddresses>
</host>
<endpoint address="" binding="netTcpBinding" bindingConfiguration="DuplexNetTcpBinding_IService1" contract="WcfService_using_callbacks_via_tcp.IService1"/>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="mexTcp" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<!--
TCP Binding
-->
<netTcpBinding>
<binding name="DuplexNetTcpBinding_IService1" sendTimeout="00:00:01"
portSharingEnabled="true">
</binding>
<binding name="mexTcp" portSharingEnabled="true">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<!--
Behaviour to avoid a rush of clients and to expose metadata over tcp
-->
<behavior name="Behaviour_Service1">
<serviceThrottling maxConcurrentSessions="10000"/>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
그리고 생
나는 아주 작은 서비스를
static void Main(string[] args)
{
Uri base_address = new Uri("net.tcp://localhost:5050/Service1");
ServiceHost host = null;
try
{
// Create the server
host = new ServiceHost(typeof(Service1), base_address);
// Start the server
host.Open();
// Notify it
Console.WriteLine("The service is ready at {0}", base_address);
// Allow close the server
Console.WriteLine("Press <Enter> to stop the service.");
Console.ReadLine();
// Close it
host.Close();
}
catch (Exception ex)
{
// Opus an error occurred
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(string.Format("Host error:\r\n{0}:\r\n{1}", ex.GetType(), ex.Message));
Console.ReadLine();
}finally
{
// Correct memory clean
if(host != null)
((IDisposable)host).Dispose();
}
}
가 지금은 클라이언트를 만들려면,하지만 난 그것을 추적 할 수없는 가망되지 않습니다 :의 코드는 호스트합니다. 나는 서비스 참조를 추가하고 직접적으로는 svcutil 사용했지만,이 오류를 받고 있어요 :
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>svcutil.exe net.tcp://loc alhost:5050/Service1 Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1] Copyright (c) Microsoft Corporation. All rights reserved.
Attempting to download metadata from 'net.tcp://localhost:5050/Service1' using W S-Metadata Exchange. This URL does not support DISCO. Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1] Copyright (c) Microsoft Corporation. All rights reserved.
Error: Cannot obtain Metadata from net.tcp://localhost:5050/Service1
If this is a Windows (R) Communication Foundation service to which you have acce ss, please check that you have enabled metadata publishing at the specified addr ess. For help enabling metadata publishing, please refer to the MSDN documentat ion at http://go.microsoft.com/fwlink/?LinkId=65455 .
WS-Metadata Exchange Error URI: net.tcp://localhost:5050/Service1
Metadata contains a reference that cannot be resolved: 'net.tcp://localhost: 5050/Service1'.
The socket connection was aborted. This could be caused by an error processi ng your message or a receive timeout being exceeded by the remote host, or an un derlying network resource issue. Local socket timeout was '00:04:59.9863281'.
Se ha forzado la interrupción de una conexión existente por el host remoto
If you would like more help, type "svcutil /?"
그래서, 문제없이 서비스를 호스팅 할 수 있지만 프록시를 만들 수 없습니다.
내가 찾은 거의 모든 설정을 시도했지만 현재 web.config가 올바른 것 같습니다. 엔드 포인트에서 사용되는 mex를 사용하는 동작, 보안 및 바인딩이 있습니다.
app.config를 만들고 svcutil.exe를 사용하여 같은 폴더로 설정하려고했습니다.
@ JohnSaunders, 나는 평판이있는 누군가가 응답 코드를 질문 코드에 복사하여이 전체 질문을 완전히 무효화하는 이유를 이해할 수 없습니다. 나는 누군가가 당신이 한 일을했다는 것을 깨닫기 전에 질문 코드와 응답 코드의 차이점을 찾기 위해 시간을 낭비했다. 아무도 실제 질문이 무엇인지 알 수 없었습니다. – Sheridan
@Sheridan : 여기에 큰 힌트가 있습니다. "어떻게 이해할 수 없는가", 또는 "어떻게 볼 수 없는가"와 같은 말을 발견 할 때마다 그것이 당신의 이해 또는 비전의 문제 일 수 있다고 생각하십시오. . 내가 어떻게하지 않았기 때문에 당신은 "어떻게 이해할 수 없다". 방금 코드를 들여 썼습니다. 편집 내역을 자세히 살펴보십시오. 난 그냥했다. –
* * * 내 의견을보기 전에 * 가까이에 * 보았습니다. 귀하의 의견을 수락하는 동안 나는 그 코드를 추가 한 것처럼 * 여전히 * 나타납니다. 아아 ... 그냥 * Side by Side *보기. 다른 견해들에서 나는 진실 된 그림을 볼 수있다. 죄송합니다 ... 나는 논평하기 전에 좀 더 자세히보아야했습니다. – Sheridan