WCF 服务的负载平衡错误 - NLB

发布于 2024-07-12 13:33:06 字数 3460 浏览 11 评论 0原文

更新3:
我创建了一个 Visual Studio 2008 测试项目,并尝试创建对共享站点 WCF 服务引用的服务引用,但收到以下错误:

下载时出错 'http://apps.mydomain/MyService.svc'。 请求失败,状态为 HTTP 400:错误的请求。 元数据包含一个 无法解决的参考: 'http://apps.mydomain/MyService.svc'。 内容类型 application/soap+xml; 不支持 charset=utf-8 服务 http://apps.mydomain/MyService.svc'。 客户端和服务绑定可能是 不匹配。 远程服务器返回 错误:(415) 无法处理 消息,因为内容类型 '应用程序/soap+xml; 字符集=utf-8' 不是预期的类型 'text/xml; charset=utf-8'..如果服务是 在当前解决方案中定义,尝试 构建解决方案并添加 再次参考服务。

更新2:
@Nick - 我尝试了您的建议,即使用每个服务器的完全限定路径明确设置每个端点的地址,但我仍然得到相同的结果。

此外,当我尝试使用共享站点 URL 设置 ListenUri 属性时,我收到 400 错误请求错误而不是 404 错误。

更新
经过一些额外的研究,http://apps1.mydomainhttp://apps2.mydomain 并能够克服“服务器应用程序不可用”错误。

现在,当我尝试浏览共享网站 (http://apps.mydomain) 时,出现 404 错误,但我可以浏览到 http://apps1.mydomainhttp://apps2.mydomain 服务参考。

原始问题

我的公司使用Microsoft NLB来平衡 IIS 服务器之间的流量负载。 我最近在每台 IIS 6 Windows Server 2003 Standard Edition SP1 服务器上部署了 WCF 服务。 当我尝试使用 IE 7 浏览共享域名时收到以下错误:

服务器应用程序不可用 您正在尝试的网络应用程序 当前对该 Web 服务器的访问权限是 不可用。 请点击“刷新” 网络浏览器中的按钮重试 你的申请。

管理员注意:错误消息 详细说明造成这一现象的具体原因 请求失败可以在 Web 应用程序事件日志 服务器。 请查看此日志条目 找出导致此错误的原因 发生。

消费者将指向 http://apps.mydomain 来使用该服务,但虚拟域映射到 http://apps1.mydomainhttp ://apps2.mydomain。 如果我浏览到每台服务器上的服务,我不会收到该错误。

该服务当前使用匿名 basicHttpBinding。

还有其他人遇到过这个问题吗?

历史记录

在此错误开始发生之前,我在浏览所有三个域名时收到以下错误 (http://apps.mydomainhttp://apps1.mydomainhttp://apps2.mydomain):

此集合已包含 地址与方案http。 有可以 每个方案最多有一个地址 这个集合。

我使用 ServiceHostFactory 类来自定义我的.svc 文件来指定自定义服务工厂。 然后,我通过继承 ServiceHostFactory 并根据需要重写来创建自定义工厂。

public class MyFactory : ServiceHostFactory
{
    protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
    {
        return new ServiceHost(serviceType, baseAddresses[0]);
    }
}

<%@ ServiceHost Language="C#" Factory="MyFactory" Debug="true" Service="MyService" CodeBehind="~/App_Code/MyService.cs" %>

UPDATE 3:
I created a Visual Studio 2008 test project and tried to create a service reference to shared site WCF service reference and received the following error:

There was an error downloading
'http://apps.mydomain/MyService.svc'.
The request failed with HTTP status
400: Bad Request. Metadata contains a
reference that cannot be resolved:
'http://apps.mydomain/MyService.svc'.
Content Type application/soap+xml;
charset=utf-8 was not supported by
service
http://apps.mydomain/MyService.svc'.
The client and service bindings may be
mismatched. The remote server returned
an error: (415) Cannot process the
message because the content type
'application/soap+xml; charset=utf-8'
was not the expected type 'text/xml;
charset=utf-8'.. If the service is
defined in the current solution, try
building the solution and adding the
service reference again.

UPDATE 2:
@Nick - I tried your suggestion of explictly setting the address of each endpoint with the fully qualified path of each server and I still get the same result.

Also, when I try to set the listenUri attribute with the shared site URL, I get a 400 bad request error instead of a 404 error.

UPDATE
After some additional research, there were some IIS configuration setting conflicts between http://apps1.mydomain and http://apps2.mydomain and was able to get past the "Server Application Unavailable" error.

Now I am getting a 404 error when I tried to browse to the shared site (http://apps.mydomain), but I am able to browse to the http://apps1.mydomain and http://apps2.mydomain service reference.

Original Problem

My companys uses Microsoft NLB to load balance traffic between our IIS servers. I recently deployed a WCF service on to each IIS 6 Windows Server 2003 Standard Edition SP1 servers. I received the following error when I tried to browse to the shared domain name using IE 7:

Server Application Unavailable The
web application you are attempting to
access on this web server is currently
unavailable. Please hit the "Refresh"
button in your web browser to retry
your request.

Administrator Note: An error message
detailing the cause of this specific
request failure can be found in the
application event log of the web
server. Please review this log entry
to discover what caused this error to
occur.

The consumer will point to the http://apps.mydomain to use the service but virtual domain is mapped to http://apps1.mydomain or http://apps2.mydomain. If I browse to the service on each server, I do not receive that error.

The service is currently using a anonymous basicHttpBinding.

Has anyone else experienced this issue?

History

Before this error started occurring, I received the following error when I broswed to all three domain name (http://apps.mydomain, http://apps1.mydomain, http://apps2.mydomain):

This collection already contains an
address with scheme http. There can
be at most one address per scheme in
this collection.

I used the ServiceHostFactory class to customize my .svc file to specify a custom service factory. Then I create our custom factory by inheriting from ServiceHostFactory and overriding as required.

public class MyFactory : ServiceHostFactory
{
    protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
    {
        return new ServiceHost(serviceType, baseAddresses[0]);
    }
}

<%@ ServiceHost Language="C#" Factory="MyFactory" Debug="true" Service="MyService" CodeBehind="~/App_Code/MyService.cs" %>

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

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

发布评论

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

评论(2

世界如花海般美丽 2024-07-19 13:33:06

经过对我的 WCF 服务和消费应用程序的不同配置进行一些试验后。 我创建了对工作服务引用之一的服务引用(http://apps1.mydomainhttp://apps2.mydomain) 在使用应用程序中。 然后,我将客户端配置中的端点引用更改为指向共享站点 WCF 地址 (http://apps.mydomain )并且我能够消费和使用该服务。

After some experimenting with different configurations for my WCF service and consuming application. I created a service reference to one of the working service references (http://apps1.mydomain or http://apps2.mydomain) in the consuming application. Then I changed the endpoint reference in the client configuration to point to the shared site WCF address (http://apps.mydomain) and I was able to consume and use the service.

再可℃爱ぅ一点好了 2024-07-19 13:33:06

我之前遇到过 WCF 和负载平衡的问题,其中服务器有多个具有不同 IP 地址的网卡,而 WCF 只会显示它找到的第一个 IP 地址。 我们必须在每台服务器的服务定义上显式设置 IP 地址,以便 WCF 能够绑定到正确的地址。

I've had an issue before with WCF and load balancing where the servers had multiple Network cards with different IP addresses and WCF would just pic the first IP address it found. We had to explicitly set the IP address on each server's Service Definition so WCF would bind to the right one.

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