我有一个在 NetNamedPipeBinding 端点上侦听的 ServiceHost。我有一个服务合同类,它有一个方法,由客户端调用并由服务器处理。该方法(我们称之为 PipeRequest())有一个 Request 参数。在客户端,我填充了这个对象,但是当它被发送到服务器时它是空的。任何想法为什么会这样?
_Host = new ServiceHost(typeof(PipeService), new Uri(ServiceRequestRouter.URI));
_Host.AddServiceEndpoint(
typeof(IPipeService),
new NetNamedPipeBinding(),
_PipeName
);
_Host.Open();
[ServiceContract(Namespace = "http://www.example.com/PipeCommunication")]
interface IPipeService
{
[OperationContract]
void PipeRequest(ServiceRequestBase request);
}
[DataContract]
[KnownType(typeof(DerivedServiceRequest))]
[KnownType(typeof(SomeEnumType))]
public abstract class ServiceRequestBase
{
...
public void Dispatch(string pPipeName = ServiceRequestRouter.DefaultPipeName)
{
EndpointAddress epa = new EndpointAddress(_address_));
IPipeService proxy = ChannelFactory<IPipeService>.CreateChannel(new NetNamedPipeBinding(), epa);
proxy.PipeRequest(this);
}
}