WCF错误 - 没有端点在监听。

32

我正在开发一个运行在Windows Server 2003的IIS6上的WCF服务。 我已经构建了一个测试客户端来与WCF服务通信,但是我遇到了下面的错误。 我已经花了几天时间查看这个错误,并参考了论坛上其他人的建议,但没有成功。 希望能得到帮助,非常感谢。

没有终结点侦听https://webbooking.infodata.uk.com/Synxis/Synxis.svc,可以接受消息。 这通常是由于地址或SOAP操作不正确引起的。 如有需要,请参见InnerException获取更多详细信息。

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>

当您直接从浏览器打开服务URL时,您看到了什么? - Mayo
当我打开服务的URL链接时,我看到了“您已创建了一个服务”的页面,正如预期的那样。 - Neil Hung
在您的服务配置中,您有一个端点元素,其合同属性值仅为类/接口名称,而应该是完全限定名称,即namespace.Synxis。 - Rajesh
感谢Rajesh的评论。合同属性仅为类名的原因是没有命名空间。我认为这不是什么大问题?! - Neil Hung
谢谢回复,我之前也遇到了 .svc 扩展名的问题,但是我确定它当时给出的是另一个错误信息。无论如何,下面 Tim 的答案已经解决了我的问题。 - Neil Hung
显示剩余3条评论
6个回答

16

在您的服务配置中未定义绑定,因此您正在获取wsHttpBinding的默认值,并且该绑定的securityMode\transport的默认值为Message

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

<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" />

然后,这将会把您定义的绑定(使用传输安全)分配给端点。


这就是我的问题的解决方案!谢谢! - Neil Hung
我测试了您提供的解决方案,但是没有得到答案!!http://stackoverflow.com/questions/38856971/wcf-http-binding - Farshid Shekari
我的错误在于地址属性,它的值不是空的。将该值移除后问题得到解决。 - cristiam

2

我遇到了同样的问题。我发现 HTTPS 使用了另一个证书,这个证书的过期日期无效。不确定为什么会出现这种情况。我更改了 HTTPS 端口号并生成了一个新的自签名证书。WCFtestClinet 可以通过 HTTPS 连接到服务器!


1

我在使用服务访问时遇到了相同的错误。在浏览器中它可以工作,但是当我尝试在我的asp.net/c#应用程序中访问它时就无法工作。我将应用程序池从appPoolIdentity更改为NetworkService,然后它开始工作了。对我来说似乎是权限问题。


1

在我的情况下

我的服务有一个功能是上传文件

当尝试上传大文件时,就会出现这个错误

所以我找到了this answer 来增加 web.configmaxRequestLength的值到需要的值

问题解决了

如果您没有进行任何上传或下载操作,也许这个答案对您没有帮助


1
在你给踩之前,你有上传或下载操作吗? - Basheer AL-MOMANI

1

不同的情况可能会有所帮助:

在我的情况下,服务器上启用了Windows防火墙。

可以执行以下两个操作之一:

  • 禁用Windows防火墙(自担风险,但可以使事情正常运行)。

  • 在入站规则中添加端口。

谢谢。


0

您可以通过在web.config中清除端点标记中地址的值来解决此问题:

<endpoint address="" name="wsHttpEndpoint"  .......           />

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接