共享主机上的 WCF 配置问题
我有一个 WCF 服务,可以在本地、服务器和 Azure 上正常运行。但是,我尝试将相同的代码部署到 RackSpace 站点(共享托管环境正在运行 .NET 4.0、IIS7 和 Windows Server 2008),并且当服务返回响应时,我运行时出现以下错误:
消息:[System.ServiceModel.ProtocolException] = {"响应消息的内容类型text/html与 绑定的内容类型(text/xml; 字符集=utf-8)。如果使用自定义 编码器,请确保 IsContentTypeSupported 方法是 正确实施。第1024章 资源字节数...
InnerException:_innerException = {" 远程服务器返回错误:(500) 内部服务器错误。”}
问题是,虽然响应是错误,但该方法确实成功接收数据并将其传递到数据库中,因此问题似乎出在从 WCF 方法返回到客户端应用程序的响应中以前有人遇到过这种情况吗?我知道共享托管的信任级别可能是罪魁祸首 - 但我尝试过的任何方法似乎都无法减轻我
在使用 WCF 服务的 Web 应用程序上的配置 。 :
绑定:
<binding name="BasicHttpBinding_IAccountService" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
和端点:
<client>
<endpoint address="http://sitename.com/Services/AccountService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAccountService"
contract="AccountService.IAccountService" name="BasicHttpBinding_IAccountService" /></client>
这是使用“添加服务引用”时生成的默认绑定/端点
托管 WCF 服务的应用程序不使用任何自定义配置,但以下是其 Web.Config 的行为部分:
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
I have a WCF Service that works fine locally, on a server and on Azure. However i am trying to deploy the same code to RackSpace Sites (Shared Hosting Environment is running .NET 4.0. IIS7 & Windows Server 2008) and am running in the following error when the service returns a response:
Message:[System.ServiceModel.ProtocolException]
= {"The content type text/html of the response message does not match the
content type of the binding (text/xml;
charset=utf-8). If using a custom
encoder, be sure that the
IsContentTypeSupported method is
implemented properly. The first 1024
bytes of the res...InnerException:_innerException = {"The
remote server returned an error: (500)
Internal Server Error."}
The thing is, although the response is an error, the method does successfully receive the data and pass it into the data base, So the issue seems to be in the response back from the WCF Method to the client application. Has anyone run into this before? I know that the trust levels on shared hosting might be to blame - but nothing I have tried has seemed to alleviate the errors I'm getting.
Here is my configuration on the web application consuming the WCF Service:
The Binding:
<binding name="BasicHttpBinding_IAccountService" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
And the endpoint:
<client>
<endpoint address="http://sitename.com/Services/AccountService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAccountService"
contract="AccountService.IAccountService" name="BasicHttpBinding_IAccountService" /></client>
This is the default binding/endpoint generated when using "Add Service Reference"
The app hosting the WCF Service does not use any custom configurations, but here is the behaviours portion of it's Web.Config:
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论