gpt4 book ai didi

c# - 添加对 Web 服务的引用

转载 作者:太空宇宙 更新时间:2023-11-03 11:06:33 24 4
gpt4 key购买 nike

我正在从 wsdl 生成 Web 服务,并且其中有一些方法和属性。

[System.ServiceModel.OperationContractAttribute(Action="http://link/update", ReplyAction="*")]
WebServices.updateResponse update(WebServices.updateRequest request);

当我尝试在我的 VS2010 项目中添加对此服务的引用时,根本没有任何方法。

更改属性后

[System.ServiceModel.OperationContract]
WebServices.updateResponse update(WebServices.updateRequest request);

所有的方法都可用。

第一种情况有什么问题?

最佳答案

System.ServiceModel.OperationContract - 是 System.ServiceModel.OperationContractAttribute 的简短版本。问题出在您的 ReplyAction="*"中,它破坏了您的元数据(意味着 WsdlExporter 将忽略该操作)。尝试将其设置为任何其他值。

来自 MSDN(http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontractattribute.replyaction.aspx):

In addition to specifying a particular value for the action header of the reply message, you can also specify the string "*" (an asterisk). Specifying an asterisk in the service instructs WCF not to add a reply action to the message, which is useful if you are programming against messages directly. Specifying an asterisk in a client application instructs WCF not to validate the reply action.

关于c# - 添加对 Web 服务的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15660844/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com