I try to do the following:
I have a Windows service which is running a TCP WCF service.
Now, I want to implement a client, which can connect to this service. But this client doesn't know the contract of the service. He knows that the service does provide a method Download (string path)
. I want to connect to the service and call Download("c:\\temp\\xxx.exe")
.
I have tried the following:
var myBinding = new NetTcpBinding(SecurityMode.None)
{
TransferMode = TransferMode.Streamed,
MaxBufferPoolSize = 524288,
MaxBufferSize = 2147483647,
MaxConnections = 254,
MaxReceivedMessageSize = 2147483647,
PortSharingEnabled = true
};
var myEndpoint = new EndpointAddress("net.tcp://localhost:6648/InstallerBootstrapperService");
var myChannelFactory = new ChannelFactory<IInstallerBootstrapperService>(myBinding, myEndpoint);
IInstallerBootstrapperService client = null;
try {
client = myChannelFactory.CreateChannel();
client.Download("c:\\temp\\xxx.exe");
((ICommunicationObject) client).Close();
} catch {
if (client != null) {
((ICommunicationObject) client).Abort();
}
}
But this throw an Exception when I call Download()
. It says:
The message with Action 'Prayon.Service.Library/IInstallerBootstrapperService/Download' 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).
Is there a way that I can call the service method without knowing the contract? Can I change something on the service side, that this client can always call the method?