【发布时间】:2018-01-24 14:10:31
【问题描述】:
使用 Visual Studio 2017 15.5.4 (.NET 4.7.02053),我可以创建一个控制台应用程序,然后添加一个服务引用,该服务引用生成一个具有同步签名和基于任务的异步签名的代理。
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="urn:hpexstream-services/Engine", ConfigurationName="ServiceReference1.EngineWebService")]
public interface EngineWebService {
// CODEGEN: Parameter 'return' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
[System.ServiceModel.OperationContractAttribute(Action="urn:hpexstream-services/Engine:EngineWebService:ComposeRequest", ReplyAction="urn:hpexstream-services/Engine:EngineWebService:ComposeResponse")]
[System.ServiceModel.FaultContractAttribute(typeof(ConsoleApp4.ServiceReference1.EngineServiceException), Action="urn:hpexstream-services/Engine:EngineWebService:Compose:Fault:EngineServiceExcept" +
"ion", Name="EngineServiceException")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
[return: System.ServiceModel.MessageParameterAttribute(Name="return")]
ConsoleApp4.ServiceReference1.ComposeResponse Compose(ConsoleApp4.ServiceReference1.ComposeRequest request);
[System.ServiceModel.OperationContractAttribute(Action="urn:hpexstream-services/Engine:EngineWebService:ComposeRequest", ReplyAction="urn:hpexstream-services/Engine:EngineWebService:ComposeResponse")]
System.Threading.Tasks.Task<ConsoleApp4.ServiceReference1.ComposeResponse> ComposeAsync(ConsoleApp4.ServiceReference1.ComposeRequest request);
}
但是,当我使用 Developer Command Prompt v15.5.4 和 Svcutil.exe 生成相同的代理时,我得到的只是基于经典 IAsyncResult 的 Begin 和 End 方法。以下是我尝试过的各种命令语句:
D:\xyz>svcutil http://example.com/EngineService/EngineService?wsdl /async
D:\xyz>svcutil http://example.com/EngineService/EngineService?wsdl /async /tcv:Version35
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="urn:hpexstream-services/Engine", ConfigurationName="EngineWebService")]
public interface EngineWebService
{
// CODEGEN: Parameter 'return' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
[System.ServiceModel.OperationContractAttribute(Action="urn:hpexstream-services/Engine:EngineWebService:ComposeRequest", ReplyAction="urn:hpexstream-services/Engine:EngineWebService:ComposeResponse")]
[System.ServiceModel.FaultContractAttribute(typeof(hpexstreamservices.Engine.EngineServiceException), Action="urn:hpexstream-services/Engine:EngineWebService:Compose:Fault:EngineServiceExcept" +
"ion", Name="EngineServiceException")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
[return: System.ServiceModel.MessageParameterAttribute(Name="return")]
ComposeResponse Compose(ComposeRequest request);
[System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="urn:hpexstream-services/Engine:EngineWebService:ComposeRequest", ReplyAction="urn:hpexstream-services/Engine:EngineWebService:ComposeResponse")]
System.IAsyncResult BeginCompose(ComposeRequest request, System.AsyncCallback callback, object asyncState);
ComposeResponse EndCompose(System.IAsyncResult result);
}
强制 Svcutil 使用基于任务的签名生成轻量级代理的技巧是什么?
谢谢你, 斯蒂芬
【问题讨论】:
-
尝试将 /async 移到 URL 前...
-
你有没有把它绑起来,知道它有效,还是你在猜测?
-
基本上是猜测,因为文档没有明确说明需要哪个顺序。