我目前正在制作 WCF 服务,并且在开发该服务时表现得像它应该的那样(使用 Visual Studio Web Expres)。我有一个正在使用该服务的 Silverlight 应用程序。
我在类库中编写了 WCF 服务,并由 ASP.NET Web 应用程序实现。当我使用 Visual Studio ASP.NET 开发服务器时,该服务很高兴,并为我提供了我所要求的一切。
现在我在 IIS 7 服务器上实现了该服务。而且该服务不再返回我要求的内容。相反,在 Chrome 中,我收到以下消息:
但是,如果我浏览到服务 url,那么服务会说它已经准备好摇滚:
正如您在我从 Chrome 得到的错误中看到的那样,服务返回的文本是该“冲浪到”页面的源代码。
我的 Web.config 服务模型:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding_OnlineCreatorServiceContract" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="OnlineCreatorServiceBehavior"
name="OnlineCreator.ServiceLibrary.OrderDataService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_OnlineCreatorServiceContract"
name="basicHttpBinding" contract="OnlineCreator.ServiceLibrary.IOrderDataService" />
<endpoint address="mex" binding="mexHttpBinding" name="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="OnlineCreator.Web.OnlineCreatorServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="OnlineCreatorServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
还有我的 ServiceReferences.ClientConfig:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://subdomain.domain.com/mapWithServiceInIt/OnlineCreatorService.svc"
binding="basicHttpBinding" bindingConfiguration="basicHttpBinding"
contract="OnlineCreatorService.IOrderDataService" name="basicHttpBinding" />
</client>
</system.serviceModel>
</configuration>
因为我的服务在一个子域上,所以我习惯于关注 ClientAccessPolicy.xml:
<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
正如你所看到的,这不是问题,但为了完整起见,我把它放在这里。
这是我的第一个 WCF 服务,它运行良好,直到我将它放在 IIS 服务器上。有谁知道我为什么会收到这个错误以及如何解决它?