我试图了解Windows身份验证/加密如何与WCF中的NetTcpBinding一起使用.我需要确切地知道使用什么加密算法来加密通过线路传输的数据(以及一些证明它的文档).如果客户端和/或主机不在域上,Windows身份验证/加密是否仍然有效?
我正在尝试使用NetTcpBinding设置WcfService.我使用传输模式流式传输,因为我将传输大文件.我需要使用Session,我已经读过NetTcpBinding支持这个,但当我打开它时:
SessionMode=SessionMode.Required
Run Code Online (Sandbox Code Playgroud)
我收到错误:
System.InvalidOperationException:Contract需要Session,但Binding'NetTcpBinding'不支持它,或者没有正确配置以支持它.
有谁知道我必须做什么才能使NetTcpBinding与会话一起工作?谢谢你的帮助 :)
我有一种情况,我无法在Windows 7下使用net.tcp托管服务,但它在Windows 2008服务器上运行正常.我启用了WAS,并在Windows 7和Windows服务器中进行了相同的设置但由于某种原因它在Windows 7中不起作用.我在客户端获得的错误是:
System.ServiceModel.EndpointNotFoundException: The message could not be dispatched because the service at the endpoint address 'net.tcp://localhost:908/TcpTest/MySuperService.svc' is unavailable for the protocol of the address.
Server stack trace:
at System.ServiceModel.Channels.ConnectionUpgradeHelper.DecodeFramingFault(ClientFramingDecoder decoder, IConnection connection, Uri via, String contentType, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open()
Run Code Online (Sandbox Code Playgroud)
在事件日志中,我收到以下服务错误:
An error occurred while trying to listen for …Run Code Online (Sandbox Code Playgroud) 假设我有一个服务暴露两个端点,第一个是NetTCPBinding,第二个是HttpBinding的任何风格.他们都实现完全相同的服务合同.
电线上发送的内容有什么区别?
我认为在所有情况下,在将消息放到线路上之前它将被转换为二进制文件,因此http在网络术语中也位于tcp之上 - 因此http通信需要额外的空间.
欣赏这个问题有点模糊,但希望有人会知道我想问的是什么:)
wcf basichttpbinding wcf-binding wshttpbinding nettcpbinding
我们正在开发一个 Silverlight 4/5 应用程序,该应用程序通过由 Windows 服务托管的 NetTcp WCF 服务与服务器进行通信。
在某些情况下,我们会收到SfxServerDidNotReply错误
这在网上几乎没有记录。遇到同样错误的人还没有在任何地方发布任何答案。
这是一个没有给出答案的 MSDN 线程。
我们还可以在这个ServiceChannel.cs类中找到参考。但这段代码似乎仅在通道为双向时才会抛出异常,而我们的情况并非如此。
此外,此错误发生在客户端,监控服务服务器端没有显示任何内容。
任何想法?这里有 WCF 专家吗?
我已阅读MSDN上提供的文档以及本网站上的其他一些帖子.但是,当使用带有证书的消息安全性时,WCF(特别是NetTcpBinding)是否会实际加密消息内容仍然有点不清楚.有人有确切消息么?
例如,您可以在配置中指定传输和消息凭据:
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Certificate"/>
<message clientCredentialType="Certificate"
negotiateServiceCredential="true" />
</security>
Run Code Online (Sandbox Code Playgroud)
据我所知,MSDN文档暗示消息安全性仅依赖于用户名/密码或基于证书的身份验证(协商),但没有具体说明消息本身实际上是在消息级别加密的.
例如,如果我只使用消息安全性,基于证书的协商,我不认为消息内容实际上是加密的(即,数据包嗅探器可以拦截原始消息内容 - 即使服务强制执行身份验证)?
如果可以进行真正的消息级加密(使用NetTcpBinding),如何在代码中完成?我相信这与AlgorithmSuite有关,虽然我不确定,
binding.Security.Mode = SecurityMode.Message;
binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
binding.Security.Message.AlgorithmSuite = new System.ServiceModel.Security.TripleDesSecurityAlgorithmSuite();
Run Code Online (Sandbox Code Playgroud) 我有一个设置为PerCall的WCF服务
我想知道如何从客户端发送一个Start调用以启动一个长时间运行的进程,并发送一个Cancel命令来取消它
我的WCF服务看起来像这样
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class Service1 : IService1
{
CancellationTokenSource cancelToken = new CancellationTokenSource();
public void Start()
{
var compute = Task.Factory.StartNew(StartLongRunningTask, cancelToken.Token);
}
public void Stop()
{
cancelToken.Cancel();
}
private void StartLongRunningTask()
{
//process here
}
}
Run Code Online (Sandbox Code Playgroud)
我想这里的问题是,每次呼叫到达服务器时,它都被视为新请求.
那么如何在WCF中启动和取消长时间运行的任务呢?
编辑:我将它作为Windows服务托管
我安装了一个Windows应用程序,它使用了WCF服务,我只是通过以下配置在Windows服务中托管网络tcp绑定的WCF服务的配置文件,我想知道客户端如何能够使用这个WCF服务.应用程序使用此服务来填充UI中的数据,并且它可以正常工作.当我尝试使用它时,我无法通过WCF测试客户端这样做.那么应用程序如何使用此服务?
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_FirstBindingServiceContract" closeTimeout="00:10:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="999999999" maxBufferSize="999999999" maxConnections="10"
maxReceivedMessageSize="999999999">
<readerQuotas maxDepth="999999999"
maxStringContentLength="999999999"
maxArrayLength="999999999"
maxBytesPerRead="999999999"
maxNameTableCharCount="999999999" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehaviors">
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="MyService.DataAccessService" behaviorConfiguration="MyServiceBehaviors">
<endpoint bindingConfiguration="NetTcpBinding_FirstBindingServiceContract"
name="firstBinding" address="net.tcp://localhost:25488/MyDataAccessService/MyFirstBindingAddress"
binding="netTcpBinding"
contract="MyDataService.IMyDataAccessService">
</endpoint>
</service>
</services>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud) 我们有用于扑克桌面游戏的(多个)客户端-(一个)服务器架构。我们正在使用回调通道使用回调通知。
但有时由于互联网连接中断,该特定客户端与服务器断开连接,该特定客户端的 WCF 通道也进入故障状态,位于服务器的回调通道也发生故障。
设想 :
该客户端正在玩游戏,而互联网连接断开,该游戏已停止,但他的游戏窗口仍然保持打开状态,当他/她的互联网连接恢复时,该客户端从服务器中退出,但该玩家的游戏窗口仍然打开,该玩家可以当他/她的 WCF 频道退出时,不要做任何事情。
我们希望在他/她从服务器退出并抛出“ CommunicationObjectAbortedException ”异常时关闭该特定客户端的窗口。
我们不能使用以前的 WCF 通道的回调通道,因为它处于故障状态。因此,我们尝试在使用以下代码删除的同时在服务器中创建新的 callbackChannel:
操作上下文。当前.GetCallbackChannel();
但是这里 Current 显示“ NULL ”,因为该播放器的 WCF 通道被中止,因此它抛出“对象引用未设置为对象实例”的错误。
那么是否有任何解决方案可以使用中止的 WCF 通道的回调通道或恢复该 WCF 通道而不重新初始化它们或使用新通道调用该客户端?
我在使用netTcpBinding WCF客户端/服务器进行回调时遇到了一些问题.这是代码...任何想法?
服务方
合同:
using System.Runtime.Serialization;
using System.ServiceModel;
namespace API.Interface
{
[ServiceContract(CallbackContract = typeof(IServiceCallback))]
public interface IMyService
{
[OperationContract]
void DoSomething();
}
public interface IServiceCallback
{
[OperationContract(IsOneWay = true)]
void OnCallback();
}
}
Run Code Online (Sandbox Code Playgroud)
服务:
using System;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using System.Timers;
using API.Interface;
namespace API.Service
{
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Reentrant)]
public class MyService : IMyService
{
public static IServiceCallback callback;
public static Timer Timer;
public void DoSomething()
{
Console.WriteLine("> Session opened at {0}", DateTime.Now);
callback = OperationContext.Current.GetCallbackChannel<IServiceCallback>(); …Run Code Online (Sandbox Code Playgroud) nettcpbinding ×10
wcf ×10
c# ×3
.net ×1
callback ×1
certificate ×1
iis ×1
security ×1
session ×1
silverlight ×1
streaming ×1
wcf-binding ×1
windows-7 ×1