在ServiceModel客户端配置节找不到终结点元素名为'为XXXXX'和合同'YYY“ [英] Could not find endpoint element with name 'xxxxx' and contract 'yyy' in the ServiceModel client configuration section
问题描述
我产生通过这个命令的代理 - 结果
svcutil.exe的/语言:CS /out:generatedProxy.cs /config:app.config的 https://service100.emedny.org:9047/MHService?wsdl
I generated a proxy via this command -
svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config https://service100.emedny.org:9047/MHService?wsdl
然后再复制从生成的app.config到现有项目的app.config文件中的元素。
and then copied the elements from the resulting app.config into the app.config file of an existing project.
当我尝试访问客户端通过该配置文件 -
When I try to access the client in that config file via-
MHSClient serviceProxy =新MHSClient(MHSPort);
应该参考下面的第二个客户端:
it should reference the second client below:
<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>
而是我得到的错误;
结果
找不到名为'MHSPort和合同MHS在ServiceModel客户端配置节终结点元素。这可能是因为没有配置文件找到您的应用程序,或者是因为匹配该名称的终结点元素可以在客户端的元素被发现。
如果我去MHSClient的定义,它带我到proxy.cs文件,这条线;结果
公共部分类MHSClient:System.ServiceModel.ClientBase,MHS
If I go to definition of MHSClient, it takes me to the proxy.cs file and this line;
public partial class MHSClient : System.ServiceModel.ClientBase, MHS
结果
符合以下结果
endptAddress解决=新的EndpointAddress(新的URI(URI/ XXXX),EndpointIdentity.CreateDnsIdentity(XXXXXX),addressHeaders);结果
MHSClient serviceProxy =新MHSClient(b,endptAddress);
推荐答案
您可能需要设置ServiceContractAttribute的的ConfigurationName财产上述。服务协定接口,ConfigurationName应该与你的合同名称
You probably need to set the ConfigurationName property of the ServiceContractAttribute above the service contract interface, ConfigurationName should match your contract name.
'VB.NET:
Imports System.ServiceModel
<ServiceContract([Namespace]:="http://yournamespace", ConfigurationName:="MHS")> _
Public Interface MHS
//C#:
using System.ServiceModel;
[ServiceContract(Namespace="http://yournamespace", ConfigurationName="MHS")]
public interface MHS
看一下自动生成的代码在这里:
的 MSDN:如何创建一个Windows通讯基础客户
Look at the auto generated code here: MSDN: How to: Create a Windows Communication Foundation Client
另外值得一看:
的 MSDN:ServiceContractAttribute的类
这篇关于在ServiceModel客户端配置节找不到终结点元素名为'为XXXXX'和合同'YYY“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!