ruft Ich habe einen WCF-Dienst, für die ich eine Schnittstelle erzeugt, um den folgenden Befehl:Importieren von C# DLL, die Power WCF Funktionalität
svcutil.exe net.pipe://localhost/myService/MEX
Ich habe eine neue Bindung wie folgt:
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);
Als ich versuchte, das Modul in PowerShell zu verwenden, bekam ich den folgenden Fehler:
Write-File : The message with Action ' http://tempuri.org/IMyService/StartDisk ' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
At line:1 char:1
Write-File bla -verbose
~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : NotSpecified: (:) [Write-File], ActionNotSupportedException
FullyQualifiedErrorId : System.ServiceModel.ActionNotSupportedException,DLM.Module.WriteFile
Ich benutze [ProtoContract]
als Serialisierungsprotokoll. Ich musste es manuell zu der IMyService-Schnittstelle hinzufügen, die von dem SvcUtil.exe-Befehl generiert wurde.
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();
Haben Sie irgendwelche Gedanken zu diesem Thema?
Ich benutze Named Pipes und ich möchte nicht http verwenden, um die Metadaten zu erhalten und daher mit mex. Sie können über den Unterschied [hier] lesen (http://blogs.microsoft.co.il/idof/2011/08/10/wsdl-vs-mex-knockout-or-tie/) –
Ja, ich verstehe. Aber das ist es, was Sie für svcutil.exe verwenden, um eine 'IService'-Schnittstelle für Sie zu erstellen. Aber wenn Sie einen Kanal erstellen, brauchen Sie kein "MEX" Suffix. Versuchen Sie den 'EndpointAddress'-Konstruktor zu ändern:' new EndpointAddress ("net.pipe: // localhost/myService") ', da ich glaube, dass der Hauptdienst (mit Aktionen wie' StartDisk' auf 'net.pipe:/wartet)/localhost/myService' Endpunkt). –
Ich habe die serverseitige Endpunktdefinition hinzugefügt –