我通过这个命令生成了一个代理 -
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>
但是我得到了错误;
在 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);