C# 使用消息约定对象调用WCF代理

C# 使用消息约定对象调用WCF代理,c#,wcf,C#,Wcf,使用SvcUtil.exe生成WCF客户端代理时,生成的代码包含表示消息约定的类(例如ImportDocument&ImportDocument_结果) 如何通过向端点发送此类类的对象作为请求来调用WCF操作,而不必调用操作方法并提供所有参数 所以不是 var proxy = new WebService_PortClient("endpointConfigurationName"); string result = proxy.ImportDocument("aNumber", "aLocat

使用SvcUtil.exe生成WCF客户端代理时,生成的代码包含表示消息约定的类(例如ImportDocument&ImportDocument_结果)

如何通过向端点发送此类类的对象作为请求来调用WCF操作,而不必调用操作方法并提供所有参数

所以不是

var proxy = new WebService_PortClient("endpointConfigurationName");
string result = proxy.ImportDocument("aNumber", "aLocation", "aType", "aDescription");
我想:

 var proxy = new WebService_PortClient("endpointConfigurationName");
 ImportDocument request = new ImportDocument
 {
     Number = "aNumber",
     Location = "aLocation",
     Type = "aType",
     Description = "aDescription"
 };

var response = (ImportDocument_Result)proxy.Invoke(request);
string result = response.return_value;

上面的代码使用Invoke方法,但该方法不存在。是否有类似于这种调用方法的可用方法?

如果已配置,则仅限
WCF
services exchange
MessageContract
s。如果已配置,则仅限
WCF
services exchange
MessageContract
s。