简体   繁体   English

在 ServiceModel 客户端配置部分中找不到名称为“xxxxx”且合同为“yyy”的端点元素

[英]Could not find endpoint element with name 'xxxxx' and contract 'yyy' in the ServiceModel client configuration section

I generated a proxy via this command -我通过这个命令生成了一个代理 -
svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config https://service100.emedny.org:9047/MHService?wsdl svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config https://service100.emedny.org:9047/MHService?wsdl

and then copied the elements from the resulting app.config into the app.config file of an existing project.然后将生成的 app.config 中的元素复制到现有项目的 app.config 文件中。

When I try to access the client in that config file via-当我尝试通过以下方式访问该配置文件中的客户端时

MHSClient serviceProxy = new MHSClient("MHSPort"); MHSClient serviceProxy = new 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>

but instead I get the error;但是我得到了错误;
Could not find endpoint element with name 'MHSPort' and contract 'MHS' in the ServiceModel client configuration section.在 ServiceModel 客户端配置部分中找不到名称为“MHSPort”且合同为“MHS”的端点元素。 This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.'这可能是因为找不到您的应用程序的配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。

If I go to definition of MHSClient, it takes me to the proxy.cs file and this line;如果我转到 MHSClient 的定义,它会将我带到 proxy.cs 文件和这一行;
public partial class MHSClient : System.ServiceModel.ClientBase, MHS公共部分类 MHSClient : System.ServiceModel.ClientBase, MHS


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

solved with the following-解决了以下问题-
endptAddress = new EndpointAddress(new Uri("uri"/xxxx"), EndpointIdentity.CreateDnsIdentity("xxxxxx"), addressHeaders); endptAddress = new EndpointAddress(new Uri("uri"/xxxx"), EndpointIdentity.CreateDnsIdentity("xxxxxx"), addressHeaders);

MHSClient serviceProxy = new MHSClient(b, endptAddress); MHSClient serviceProxy = new MHSClient(b, endptAddress);

@Guanxi gave me the clue when asking about endpoint address from the config file. @Guanxi 在从配置文件中询问端点地址时给了我线索。
Once I created the endpoint address then I could instantiate/create the service using the correct overload;一旦我创建了端点地址,我就可以使用正确的重载实例化/创建服务;
var b = new CustomBinding() as the first argument and for the second argument, var b = new CustomBinding() 作为第一个参数和第二个参数,
the correct endpoint address.正确的端点地址。

complicated - WS-Security - IBM Websphere server interop <-> wcf client复杂 - WS-Security - IBM Websphere 服务器互操作 <-> wcf 客户端
within the context of various .NET and Visual Studio implementations of web services...在 Web 服务的各种 .NET 和 Visual Studio 实现的上下文中......
oh my天啊

You probably need to set the ConfigurationName property of the ServiceContractAttribute above the service contract interface, ConfigurationName should match your contract name.您可能需要在服务协定接口上方设置 ServiceContractAttribute 的 ConfigurationName 属性,ConfigurationName 应与您的协定名称匹配。

'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

Look at the auto generated code here: MSDN: How to: Create a Windows Communication Foundation Client在此处查看自动生成的代码: MSDN:如何:创建 Windows Communication Foundation 客户端

Also worth looking at: MSDN: ServiceContractAttribute Class同样值得一看: MSDN:ServiceContractAttribute 类

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在ServiceModel客户端配置部分中找不到名称为``and contract&#39;&#39;的终结点元素 - Could not find endpoint element with name '' and contract '' in the ServiceModel client configuration section 在ServiceModel客户端配置部分中找不到引用合同的默认端点元素。 - Could not find default endpoint element that references contract… in the ServiceModel client configuration section 无法在ServiceModel客户端配置部分中找到引用合同“IAuthenticationService”的默认端点元素 - Could not find default endpoint element that references contract 'IAuthenticationService' in the ServiceModel client configuration section 在ServiceModel客户端配置部分中找不到引用contract的默认终结点元素。 - Could not find default endpoint element that references contract.in the ServiceModel client configuration section 无法找到名称和合同的端点元素 - Could not find endpoint element with name and contract C#-找不到名称为“ XXXXXX”和合同的终结点元素 - C# - Could not find endpoint element with name 'XXXXXX' and contract 找不到引用合同的默认端点元素 - Could not find default endpoint element that references contract 找不到引用合同的默认端点元素 - Could not find default endpoint element that references contract 找不到引用合同的默认端点元素 - Could not find default endpoint element that references contract 找不到引用合同的默认端点元素? - Could not find default endpoint element that references contract?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM