【发布时间】:2015-10-28 10:32:16
【问题描述】:
继续 this 和 this 问题。 我有两个使用相同方法的服务合同:
[ServiceContract]
public interface IServices1
{
[OperationContract]
string GetData(int value);
}
[ServiceContract]
public interface IServices2
{
[OperationContract]
string GetData(int value);
}
和服务:
public class Service : IServices1, IServices2
{
string IServices1.GetData(int value)
{
return string.Format("You entered: {0}", value);
}
string IServices2.GetData(int value)
{
return string.Format("You entered: {0}", value);
}
}
由于我无法控制的原因:
- this 不适合我回答,我需要保留原名。
- this 不适合我,我需要单个 wsdl 文件。如果您使用不同的命名空间,当您尝试从服务主页 (http://addresToService/Service.svc?singleWsdl) 打开单个 wsdl 时会出现错误:
System.NotSupportedException:无法为此服务生成单个 WSDL 文档。找到多个服务合同命名空间(IServices1、IServices2)。确保您的所有服务合同都具有相同的命名空间。
- 我需要一个具有多个端点的服务。
- 我需要像 this 这样的服务(最好在 WCF 上)。
总之,我需要在单个 wsdl 中具有多个具有重复方法名称的服务合同的 WCF 服务。有没有办法实现?
【问题讨论】:
-
你不能这样做,因为它相当于重载一个方法,并且在wsdl中是不允许的。在此处查看更多信息:stackoverflow.com/questions/10276124/… 和此处:w3.org/TR/2002/WD-wsdl12-20020709
-
@RicardoPontual 如何使用 WCF 获得像 this 这样的 wsdl?在这个 wsdl 中,
<portType name="RegistrationSoapPort">有<operation name="AcceptRequest" parameterOrder="RequestID">和<portType name="CertRequestSoapPort">有<operation name="AcceptRequest" parameterOrder="RequestID Request">在一个命名空间中。 -
我作为答案发布,因为评论有点长
-
您必须在 Web 中配置两个端点。 config,那么它也可以显示SingleWsdl
标签: c# web-services wcf soap wsdl