成功添加服务引用后,WCF 无法连接到端点

发布于 2024-12-11 00:39:55 字数 2280 浏览 0 评论 0原文

我已在我们的生产服务器上成功发布了 WCF 服务。我可以导航到该页面并查看默认的 WCF 页面。

我可以通过“添加服务引用”将服务添加到我的计算机上的客户端。我还可以毫无问题地“更新服务参考”。

通过运行 VS2010 附带的默认调试器,该服务已被确认可以在我的本地计算机上运行(无论是否有客户端)。

当尝试调用服务方法(从服务器托管服务)时,我收到此异常。

没有侦听端点可以接受该消息。这通常是由不正确的地址或 SOAP 操作引起的。有关更多详细信息,请参阅 InnerException(如果存在)。

InnerException...

{“远程服务器返回错误:(404) 未找到。”}

我还尝试在服务器本身上运行客户端以查看是否可以连接,但收到相同的错误。

我什至尝试只部署在创建 WCF 服务库时为您创建的基本 WCF 服务(非常基本),没有进行任何更改,部署成功,但出现相同的错误。

我做错了什么?我已经尝试了 IIS 配置、SSL 证书等,但似乎没有任何解决办法。我觉得我在这里错过了一些非常基本的东西。

编辑客户端配置...

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00"     sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                         maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                 </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://SERVER_NAME.DOMAIN_NAME.com/TestService/TestService.Service1.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
                contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
        </client>
    </system.serviceModel>
</configuration>

I've successfully published a WCF service on our production server. I can navigate to the page and see the default WCF page.

I can add the service via "Add Service Reference" to a client on my computer. I can also "Update Service Reference" with no problems what so ever.

The service was confirmed to work on my local computer with and without the client by running the default debugger that comes with VS2010.

When trying to call a service method (from the server hosted service), I receive this exception..

There was no endpoint listening at that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

InnerException...

{"The remote server returned an error: (404) Not Found."}

I've also tried running a client on the server itself to see if I can connect but I get the same error.

I even tried just deploying the basic WCF service that's created for you when you create a WCF service library (very basic), changed nothing, deployed successfully, and get the same error.

What am I doing wrong? I've went down the road of IIS configurations, SSL certificates, etc but nothing seems to fix it. I feel as though I'm missing something very basic here.

EDIT CLIENT CONFIG...

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00"     sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                         maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                 </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://SERVER_NAME.DOMAIN_NAME.com/TestService/TestService.Service1.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
                contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
        </client>
    </system.serviceModel>
</configuration>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拍不死你 2024-12-18 00:39:55

需要检查的一些陷阱:

1) 检查配置文件中的服务 URL 是否正确。这包括协议。最近发生在我身上:.config 文件有“http://”,而网络服务器只能通过 HTTPS 访问。

2) 禁用 IIS 上的“必需的客户端证书”设置。

3) 如果您的服务位于 ASP.NET 应用程序内,请检查是否存在任何身份验证/授权限制。允许匿名访问您的 .SVC

Some pitfalls to check:

1) Check if the service URL is correct on your configuration files. This includes the protocol. It happened to me recently: the .config file had "http://" and the webserver was only accessible through HTTPS.

2) Disable the "required client certificate" setting on IIS.

3) If your service is inside an asp.net application, check if there are any restrictions of Authentication / Authorization in place. Allow anonymous access to your .SVC

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文