小编use*_*361的帖子

在 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");

它应该引用下面的第二个客户端:

  <client>
  <endpoint address="https://webservices.hmsa.com/EDI27X/cstc/Hipaa27XService.svc"
            binding="customBinding" 
            bindingConfiguration="wsHttpEndpoint" 
            contract="HIPAA27XServiceContract" 
            name="wsHttpEndpoint" />
  <endpoint address="https://12.23.28.113:9047/MHService" 
            binding="customBinding"
            bindingConfiguration="MHService_MHSPort" 
            contract="MHS"
            name="MHSPort" />
</client>
Run Code Online (Sandbox Code Playgroud)

但是我得到了错误;
在 ServiceModel 客户端配置部分中找不到名称为“MHSPort”且合同为“MHS”的端点元素。这可能是因为找不到您的应用程序的配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。

如果我转到 MHSClient 的定义,它会将我带到 proxy.cs 文件和这一行;
公共部分类 MHSClient : System.ServiceModel.ClientBase, MHS


解决了以下问题-
endptAddress = new EndpointAddress(new Uri("uri"/xxxx"), EndpointIdentity.CreateDnsIdentity("xxxxxx"), addressHeaders);
MHSClient serviceProxy = new MHSClient(b, endptAddress);

c# web-services soap-client

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

soap-client ×1

web-services ×1