无法在ServiceModel客户端配置部分中找到名称为“xxxxx”且合同“yyy”的端点元素
我通过这个命令生成了一个代理 –
svcutil.exe / language:cs /out:generatedProxy.cs /config:app.config https://service100.emedny.org:9047/MHService?wsdl
然后将生成的app.config中的元素复制到现有项目的app.config文件中。
当我尝试通过以下方式访问该配置文件中的客户端时 –
MHSClient serviceProxy = new MHSClient(“MHSPort”);
它应该引用下面的第二个客户:
但我得到了错误;
无法在ServiceModel客户端配置部分中找到名称为“MHSPort”且收缩“MHS”的端点元素。 这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。
如果我去定义MHSClient,它会将我带到proxy.cs文件和这一行;
public partial class MHSClient:System.ServiceModel.ClientBase,MHS
解决了以下问题 –
endptAddress = new EndpointAddress(new Uri(“uri”/ xxxx“),EndpointIdentity.CreateDnsIdentity(”xxxxxx“),addressHeaders);
MHSClient serviceProxy = new MHSClient(b,endptAddress);
解决了以下问题 –
endptAddress = new EndpointAddress(new Uri(“uri”/ xxxx“),EndpointIdentity.CreateDnsIdentity(”xxxxxx“),addressHeaders);
MHSClient serviceProxy = new MHSClient(b,endptAddress);
@Guanxi在从配置文件询问端点地址时给了我线索。
一旦我创建了端点地址,那么我就可以使用正确的重载来实例化/创建服务;
var b = new CustomBinding()作为第一个参数和第二个参数,
正确的端点地址。
复杂 – WS-Security – IBM Websphere服务器互操作< - > wcf客户端
在Web服务的各种.NET和Visual Studio实现的上下文中……
天啊
您可能需要在服务合约接口上方设置ServiceContractAttribute的ConfigurationName属性,ConfigurationName应与您的合同名称匹配。
'VB.NET: Imports System.ServiceModel _ Public Interface MHS //C#: using System.ServiceModel; [ServiceContract(Namespace="http://yournamespace", ConfigurationName="MHS")] public interface MHS
在这里查看自动生成的代码: MSDN:如何:创建Windows Communication Foundation客户端
另外值得一看: MSDN:ServiceContractAttribute类