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:
更新3:我创建了一个Visual Studio 2008测试项目,并尝试创建对共享站点WCF服务引用的服务引用,并收到以下错误:
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.
下载'http://apps.mydomain/MyService.svc'时出错。请求失败,HTTP状态为400:错误请求。元数据包含无法解析的引用:'http://apps.mydomain/MyService.svc'。内容类型application / soap + xml;服务http://apps.mydomain/MyService.svc'不支持charset = utf-8。客户端和服务绑定可能不匹配。远程服务器返回错误:(415)无法处理消息,因为内容类型为'application / soap + xml; charset = utf-8'不是预期的类型'text / xml; charset = utf-8'..如果在当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用。
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.
更新2:@Nick - 我尝试过你的建议,明确地用每个服务器的完全限定路径设置每个端点的地址,我仍然得到相同的结果。
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.
此外,当我尝试使用共享站点URL设置listenUri属性时,我收到400错误请求错误而不是404错误。
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.
更新经过一些额外的研究,http://apps1.mydomain和http://apps2.mydomain之间存在一些IIS配置设置冲突,并且能够超过“服务器应用程序不可用”错误。
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.
现在,当我尝试浏览共享站点(http://apps.mydomain)时,我收到404错误,但我可以浏览到http://apps1.mydomain和http://apps2.mydomain服务参考。
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:
我的公司使用Microsoft NLB来加载我们的IIS服务器之间的流量平衡。我最近在每个IIS 6 Windows Server 2003 Standard Edition SP1服务器上部署了一个WCF服务。当我尝试使用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.
服务器应用程序不可用您尝试在此Web服务器*问的Web应用程序当前不可用。请点击网络浏览器中的“刷新”按钮重试您的请求。
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.
管理员注意:可以在Web服务器的应用程序事件日志中找到详细说明此特定请求失败原因的错误消息。请查看此日志条目以了解导致此错误发生的原因。
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.
使用者将指向http://apps.mydomain以使用该服务,但虚拟域将映射到http://apps1.mydomain或http://apps2.mydomain。如果我浏览到每台服务器上的服务,我不会收到该错误。
The service is currently using a anonymous basicHttpBinding.
该服务目前正在使用匿名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):
在此错误开始之前,当我浏览到所有三个域名时,我收到以下错误(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.
此集合已包含方案http的地址。此集合中每个方案最多只能有一个地址。
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.
我使用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" %>
2 个解决方案
#1
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.
在为我的WCF服务和消费应用程序进行了一些不同配置的实验之后。我在使用应用程序中创建了对其中一个工作服务引用(http://apps1.mydomain或http://apps2.mydomain)的服务引用。然后我将客户端配置中的端点引用更改为指向共享站点WCF地址(http://apps.mydomain),并且我能够使用和使用该服务。
#2
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.
我之前遇到过WCF和负载均衡问题,其中服务器有多个具有不同IP地址的网卡,而WCF只会映射它找到的第一个IP地址。我们必须在每个服务器的服务定义上明确设置IP地址,以便WCF绑定到正确的服务定义。
#1
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.
在为我的WCF服务和消费应用程序进行了一些不同配置的实验之后。我在使用应用程序中创建了对其中一个工作服务引用(http://apps1.mydomain或http://apps2.mydomain)的服务引用。然后我将客户端配置中的端点引用更改为指向共享站点WCF地址(http://apps.mydomain),并且我能够使用和使用该服务。
#2
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.
我之前遇到过WCF和负载均衡问题,其中服务器有多个具有不同IP地址的网卡,而WCF只会映射它找到的第一个IP地址。我们必须在每个服务器的服务定义上明确设置IP地址,以便WCF绑定到正确的服务定义。