我有一个 WCF 服务,我使用以下命令为其生成了一个接口:
svcutil.exe net.pipe://localhost/myService/MEX
我创建了一个新的绑定,如下所示:
var binding = new NetNamedPipeBinding();
binding.MaxBufferPoolSize = 104857600;
binding.MaxBufferSize = 104857600;
binding.MaxReceivedMessageSize = 104857600;
binding.ReaderQuotas.MaxArrayLength = 104857600;
binding.Security.Mode = NetNamedPipeSecurityMode.None;
binding.Security.Transport.ProtectionLevel = ProtectionLevel.None;
EndpointAddress endpoint = new EndpointAddress("net.pipe://localhost/myService/MEX");
IMyService service = ChannelFactory<IMyService>.CreateChannel(binding, endpoint);
当我尝试在 PowerShell 中使用该模块时,出现以下错误:
写入文件:由于 EndpointDispatcher 的 ContractFilter 不匹配,接收方无法处理带有 Action ' http://tempuri.org/IMyService/StartDisk ' 的消息。这可能是因为合约不匹配(发送方和接收方之间的操作不匹配)或发送方和接收方之间的绑定/安全不匹配。检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息、传输、无)。
在行:1 字符:1
写文件 bla -verbose
~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : NotSpecified: (:) [Write-File], ActionNotSupportedException
FullyQualifiedErrorId : System.ServiceModel.ActionNotSupportedException,DLM.Module.WriteFile
我[ProtoContract]
用作序列化协议。我不得不手动将它添加到由 SvcUtil.exe 命令生成的 IMyService 接口中。
selfHost = new ServiceHost(reqsApi, pipeBaseAddress);
var pipeBinding = new NetNamedPipeBinding();
pipeBinding.MaxBufferPoolSize = 104857600;
pipeBinding.MaxBufferSize = 104857600;
pipeBinding.MaxReceivedMessageSize = 104857600;
pipeBinding.ReaderQuotas.MaxArrayLength = 104857600;
pipeBinding.Security.Mode = NetNamedPipeSecurityMode.None;
pipeBinding.Security.Transport.ProtectionLevel = ProtectionLevel.None;
selfHost.AddServiceEndpoint(
typeof(T),
pipeBinding,
new StringBuilder().Append(serviceName).ToString());
ServiceMetadataBehavior SMB = new ServiceMetadataBehavior();
selfHost.Description.Behaviors.Add(SMB);
var behaviour = selfHost.Description.Behaviors.Find<ServiceBehaviorAttribute();
behaviour.InstanceContextMode = InstanceContextMode.Single;
var debug = selfHost.Description.Behaviors.Find<ServiceDebugBehavior();
debug.IncludeExceptionDetailInFaults = true;
var serviceEndpoint = selfHost.AddServiceEndpoint(typeof(IMetadataExchange),
MetadataExchangeBindings.CreateMexNamedPipeBinding(),
new StringBuilder().Append(serviceName).Append("/mex").ToString());
var behaviorExtension = new ProtoBuf.ServiceModel.ProtoBehaviorExtension();
对这个问题有什么想法吗?