use*_*361 5 c# web-services soap-client
我通过这个命令生成了一个代理 -
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);
解决了以下问题
- 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 服务器互操作 <->
Web 服务的各种 .NET 和 Visual Studio 实现上下文中的 wcf 客户端...
天哪