【发布时间】:2014-01-04 07:38:00
【问题描述】:
我正在使用 svcutil 使用预定义的 wsdl:
svcutil some_service.wsdl
我们正在使用它来设置一个模拟服务器来测试客户端。
生成的代码如下所示:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace = "http://LIB-Operations/interfaces/ServiceResponse", ConfigurationName = "ServiceResponse")]
public interface ServiceInterface
{
[System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action="")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
void Operation1(OperationRequest1 request);
[System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action="")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
void Operation2(OperationRequest2 request);
}
这会导致以下异常:
System.InvalidOperationException: The operations Operation1 and Operation2 have the same action (). Every operation must have a unique action value.
如果我删除
Action=""
我收到以下异常:
System.ServiceModel.ProtocolException: The one-way operation returned a fault message. The reason for the fault was 'The message with Action '' 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).'.
请注意,如果合约中只有一个操作,则没有问题。这只是在服务器中使用时的问题,在客户端中使用生成的代码时没有问题。
处理这种情况的正确方法是什么?我不能修改客户端(它必须由svcutil生成的未修改代码支持),但可以修改我们模拟服务器中使用的svcutil生成的代码。
【问题讨论】:
标签: c# wcf wsdl svcutil.exe