c# - WCF 错误 - 没有端点监听

标签 c# wcf

我正在开发一个 WCF 服务,在 Window Server 2003 上运行 IIS6。我已经构建了一个测试客户端来与 WCF 服务对话,但我收到以下错误。几天来我一直在研究这个错误,并在论坛上浏览了人们的建议,但没有运气。任何帮助将不胜感激,非常感谢

There was no endpoint listening at https://webbooking.infodata.uk.com/Synxis/Synxis.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

System.Net.WebException: The remote server returned an error: (404) Not Found.
  at System.Net.HttpWebRequest.GetResponse()
  at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)

Server stack trace: 
   at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at IOta2010A.ReservationSynch_SubmitRequest(ReservationSynchRequest request)
   at Ota2010AClient.IOta2010A.ReservationSynch_SubmitRequest(ReservationSynchRequest request) in c:\Development\WorkingFolder\Webservices\SynxisNew\App_Code\OTA2010A.cs:line 57589
   at Ota2010AClient.ReservationSynch_SubmitRequest(Security Security, DateTime& TimeStamp, String CorrelationID, String RelatesToCorrelationID, ReplyTo ReplyTo, OTA_HotelResNotifRQ OTA_HotelResNotifRQ) in c:\Development\WorkingFolder\Webservices\SynxisNew\App_Code\OTA2010A.cs:line 57601
   at Update.Page_Load(Object sender, EventArgs e) in c:\Development\WorkingFolder\Webservices\SynxisNew\Update.aspx.cs:line 72

客户端配置

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <compilation debug="true"/>
  </system.web>
  <system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="ota2010AEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00"
                receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
                transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="Transport">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true"
                        establishSecurityContext="true" />
                </security>
            </binding>
        </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://webbooking.infodata.uk.com/synxis/synxis.svc"
                binding="wsHttpBinding" bindingConfiguration="ota2010AEndpoint"
                contract="IOta2010A" name="ota2010AEndpoint" />
        </client>
    </system.serviceModel>
</configuration>

服务配置

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="Pervasive.Data.SqlClient, Version=2.10.0.34, Culture=neutral, PublicKeyToken=C84CD5C63851E072"/>
      </assemblies>
    </compilation>
    <authentication mode="Windows"/>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/> 
  </system.web>
  <system.serviceModel>
    <services>
      <service name="Synxis" behaviorConfiguration="SynxisWCF">
        <endpoint address="" name="wsHttpEndpoint"  binding="wsHttpBinding" contract="Synxis" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <diagnostics>
      <messageLogging logEntireMessage="true" logMalformedMessages="true"
         logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true"
         maxMessagesToLog="300" />
    </diagnostics>
    <behaviors>
      <serviceBehaviors>
        <behavior name="SynxisWCF" >
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" externalMetadataLocation="https://webbooking.infodata.uk.com/synxis/Synxis.svc.wsdl" />
            <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

最佳答案

您没有在您的服务配置中定义绑定(bind),因此您将获得 wsHttpBinding 的默认值,而该绑定(bind)的 securityMode\transport 的默认值是消息

尝试将您的绑定(bind)配置从客户端配置复制到您的服务配置,并通过 bindingConfiguration 属性将该绑定(bind)分配给端点:

<bindings>
  <wsHttpBinding>
    <binding name="ota2010AEndpoint" 
             .......>
      <readerQuotas maxDepth="32" ... />
        <reliableSession ordered="true" .... />
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None"
                       realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
                     establishSecurityContext="true" />
          </security>
    </binding>
  </wsHttpBinding>
</bindings>    

(截取部分配置以节省答案空间)。

<service name="Synxis" behaviorConfiguration="SynxisWCF">
    <endpoint address="" name="wsHttpEndpoint" 
              binding="wsHttpBinding" 
              bindingConfiguration="ota2010AEndpoint"
              contract="Synxis" />

这会将您定义的绑定(bind)(具有传输安全性)分配给端点。

关于c# - WCF 错误 - 没有端点监听,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17572500/

相关文章:

c# - 字符串字段的查询过滤器设计

c# - 在 Visual Studio 2010 中,在单行 C# 代码中搜索两个字符串

c# - 如何在 VS 2013 中公开托管 WCF 服务

javascript - 对 WCF 服务的跨站点 ajax 调用

c# - Xamarin - 我如何在类外使用列表

c# - Visual Studio 2015 社区 - 正则表达式查找和替换

c# - 无法在 .NET 中打开串口

c# - 如何理解服务调用是 "Restful service call"还是 "standard wcf call"?

c# - 在 azure 上托管 WCF 服务时有哪些限制(如果有)

wcf - RestartManager 导致辅助角色重新启动