【问题标题】:Web service client can't find endpoint of web serviceWeb 服务客户端找不到 Web 服务的端点
【发布时间】:2013-06-29 14:00:15
【问题描述】:

我从 Windows 服务调用了 Web 服务。引用了 Web 服务,并且所有编译都没有错误和警告。当我从 Web 服务调用方法时,我收到如下所示的错误:

    Nie można odnaleźć elementu punktu końcowego o nazwie „WSHttpBinding_IWebService” i kontrakcie „RemoteServiceLancerto.IWebService” w sekcji konfiguracji klienta ServiceModel. Może to być spowodowane tym, że nie znaleziono pliku konfiguracji dla używanej aplikacji lub tym, że w elemencie klienta nie znaleziono elementu punktu końcowego pasującego do tej nazwy.
   w System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
   w System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName, Configuration configuration)
   w System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
   w System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
   w System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
   w System.ServiceModel.ConfigurationEndpointTrait`1.CreateSimplexFactory()
   w System.ServiceModel.ConfigurationEndpointTrait`1.CreateChannelFactory()
   w System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
   w System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
   w System.ServiceModel.ClientBase`1..ctor(String endpointConfigurationName, String remoteAddress)
   w CreativiumCounterService.DatabaseSync.getWebService() w d:\Projekty\Liczniki\CreativiumCounterService\DatabaseSync.cs:wiersz 144
   w CreativiumCounterService.DatabaseSync..ctor() w d:\Projekty\Liczniki\CreativiumCounterService\DatabaseSync.cs:wiersz 30
   w CreativiumCounterService.DatabaseSync.get_Instance() w d:\Projekty\Liczniki\CreativiumCounterService\DatabaseSync.cs:wiersz 49
   w CreativiumCounterService.CounterService.syncronizerWorker(Object sender, ElapsedEventArgs e) w d:\Projekty\Liczniki\CreativiumCounterService\CreativiumCounterService.cs:wiersz 0

您可能想查看我的客户端(Windows 服务)app.config,所以我在下面显示;

<bindings>
  <wsHttpBinding>
    <binding name="WSHttpBinding_IWebService">
      <security mode="TransportWithMessageCredential">
        <transport clientCredentialType="None" />
        <message clientCredentialType="UserName" />
      </security>

    </binding>
  </wsHttpBinding>
</bindings>
<client>
  <endpoint address="https://domain.domain.com/Service/Service.svc"
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IWebService"
    contract="RemoteServiceLancerto.IWebService" name="WSHttpBinding_IWebService" />
</client>

<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="True"/>

    </behavior>
  </serviceBehaviors>
</behaviors>

当然,这只是我的配置(网络服务部分)的一部分,更改了网络服务地址。

以下是我获取 Web 服务的方法(称为 RSL):

public RSL.WebServiceClient getWebService()
        {
            PreciousData details = PreciousData.deserialize();
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IgnoreCertificateErrorHandler);
            String ConnectionString = details.getWebServiceConnectionString();

            RSL.WebServiceClient client = new RemoteServiceLancerto.WebServiceClient("WSHttpBinding_IWebService", ConnectionString);

            client.ClientCredentials.UserName.UserName = details.getWebServiceLogin();
            client.ClientCredentials.UserName.Password = details.getWebServicePassword();


client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
            return client;
        }

目前我在 IgnoreCertificateErrorHandler 中没有证书验证,但我在下面显示:

 public bool IgnoreCertificateErrorHandler(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
            System.Security.Cryptography.X509Certificates.X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            return true;
        }

此外,如果我在休闲 WinForms 应用程序中引用 Web 服务,然后我使用相同的代码从 Web 服务中调用方法,那么它就可以工作。如果需要更多详细信息,我可以提供。我必须提到,在迁移到 Web 服务后,在出现问题之前已经对 Web 服务进行了测试。我差点忘了。我从 System.Timers.Timer elapsed 事件调用 Web 服务。

【问题讨论】:

  • 请提及错误文本?? "Nie można odnaleźć elementu punktu końcowego o nazwie" 这是什么?
  • 这是“找不到具有名称的端点”

标签: c# windows wcf service web


【解决方案1】:

我发现这里提出的解决方案(第二个答案): https://stackoverflow.com//questions/3703844/consume-a-soap-web-service-without-relying-on-the-app-config 解决了我的问题,因为我在代码中创建了对象。我希望我能找到答案,为什么它不会读取 app.config 来自动创建 WSHttpBinding

【讨论】:

    猜你喜欢
    • 2014-09-04
    • 2013-02-03
    • 2010-11-09
    • 2010-09-17
    • 2011-01-06
    • 1970-01-01
    • 1970-01-01
    • 2011-03-21
    • 2020-10-23
    相关资源
    最近更新 更多