拥有一个Web应用程序。它运行2个wcf服务,并且是另一个服务器的客户端。一个wcf服务工作正常,另一个在开发服务器上不起作用,但在本地工作。错误是"内容类型text / html; charset =响应消息的UTF-8与绑定的内容类型不匹配"
Web应用程序配置的wcf部分是
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="company.eShopWorld.Wcf.eShopWorldWCFService" behaviorConfiguration="company.Web.Wcf.ServiceBehavior">
<endpoint address="" binding="basicHttpBinding" contract="Nad.CheckoutVendor.Interfaces.ICheckoutVendorService" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
<service name="company.Mobile.Wcf.MobileService" behaviorConfiguration="company.Mobile.Wcf.ServiceBehavior" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="company.Web.Wcf.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="company.Mobile.Wcf.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings />
<client>
<endpoint address="http://123.123.123.123:501/shipmentservice.svc" binding="basicHttpBinding" bindingConfiguration="" contract="Shipping.IShipmentWcfService" name="WSHttpBinding_IShipmentWcfService">
</endpoint>
</client>
测试客户端wcf配置的一部分是
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICheckoutVendorService" closeTimeout="00:02:00"
openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02: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>
<binding name="BasicHttpBinding_ICheckoutVendorService1" closeTimeout="00:02:00"
openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02: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://test.com:50128/eShopWorldService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICheckoutVendorService1"
contract="eShopWorldSvc.ICheckoutVendorService" name="BasicHttpBinding_ICheckoutVendorService" />
</client>
移动服务有效,所以我认为iis设置正确。 如果我将svc url放在浏览器中,它会向我显示服务页面,如果我将wsdl添加到url则会显示wsdl。
现在已经打了两天对这个问题,并且找不到问题。
任何帮助都是值得赞赏的
所以尝试Dimitri的建议我的web.config现在看起来像这样
<services>
<service name="company.eShopWorld.Wcf.eShopWorldWCFService" behaviorConfiguration="company.Web.Wcf.EshopServiceBehavior">
<endpoint address="/eShopWorldService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICheckoutVendorService" contract="Nad.CheckoutVendor.Interfaces.ICheckoutVendorService"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
<service name="company.Mobile.Wcf.MobileService" behaviorConfiguration="company.Mobile.Wcf.ServiceBehavior" >
<endpoint address="/MobileService.svc" binding="basicHttpBinding" contract="company.Mobile.Wcf.IMobileService" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="company.Web.Wcf.EshopServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="company.Mobile.Wcf.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICheckoutVendorService" closeTimeout="00:02:00"
openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02: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>
但我仍然有错误。请注意,我必须包含服务名称以防止404错误
我有点困惑的是,每个服务都有自己的web.config以及web应用程序的web.config。我假设他们在编译时会以某种方式卷入项目,就像他们被抛出的错误一样。还有其他想法吗? 日Thnx
答案 0 :(得分:0)
在Web应用程序(非客户端)配置中尝试此操作:
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="company.eShopWorld.Wcf.eShopWorldWCFService" behaviorConfiguration="company.Web.Wcf.ServiceBehavior">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICheckoutVendorService" contract="Nad.CheckoutVendor.Interfaces.ICheckoutVendorService" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
<service name="company.Mobile.Wcf.MobileService" behaviorConfiguration="company.Mobile.Wcf.ServiceBehavior" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="company.Web.Wcf.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="company.Mobile.Wcf.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICheckoutVendorService" closeTimeout="00:02:00"
openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02: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://123.123.123.123:501/shipmentservice.svc" binding="basicHttpBinding" bindingConfiguration="" contract="Shipping.IShipmentWcfService" name="WSHttpBinding_IShipmentWcfService">
</endpoint>
</client>
答案 1 :(得分:0)
看起来您正在尝试使用相同的服务合同配置两个不同的服务。如果您确实想这样做,只需为同一服务中的不同端点定义不同的地址值,但这可能不是很有用。
如果移动服务公开了不同的合同,那么您确实需要两种不同的服务配置,每种合同一种。在这种情况下,克隆company.eShopWorld.Wcf.eShopWorldWCFService
服务元素并更改contract
属性以使移动服务具有正确的.NET命名空间和接口类型。您还需要为每项服务单独的* .svc文件。我相信这两个服务的默认地址是这样的:
http://HostName/service.svc
http://HostName/mobileservice.svc
答案 2 :(得分:-1)
因此,问题变成了将服务名称转换为全部小写的规则。它在VS调试中没有出现问题,但在IIS
中也没有