我試圖使用wsHttpBinding
作爲Windows Azure角色部署WCF服務。無法在Azure Web角色上設置wsHttpBinding。 Web.config忽略?
當客戶端試圖連接到它,它不斷收到以下異常:
[SynchronizingContextState.Process] [System.Net.WebException: 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'..]
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
這似乎表明,該服務使用basicHttpBinding
代替。但是,我多次查看了我的Web.config
,似乎無法找到任何錯誤。此外,在Azure外部託管時,相同的服務也可以完美地工作。
我連接到Azure虛擬機並確認部署了正確的Web.config
,但它看起來好像只是被忽略,因爲我無法獲取服務元數據,即使它被假定啓用。
這是我的Web.config
文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode="Off" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="BackendServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="BackendServiceBinding" maxReceivedMessageSize="655360">
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="MyNamespace.BackendService" behaviorConfiguration="BackendServiceBehavior">
<endpoint name="Backend" address="" binding="wsHttpBinding" bindingConfiguration="BackendServiceBinding" contract="MyNamespace.IBackendService" />
<endpoint name="BackendMex" address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/BackendService.svc" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
我在這裏失去了一些東西?非常感謝你。
那麼,事實證明這是一個命名空間問題,但我看錯了地方。謝謝你的回答! – 2013-04-25 20:22:09