0

を使用して、WCF サービスを Windows Azure ロールとして展開しようとしていますwsHttpBinding

クライアントがそれに接続しようとすると、次の例外が発生し続けます。

[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 VM に接続し、正しいもの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>

ここで何か不足していますか?どうもありがとうございました。

4

2 に答える 2

1

エンドポイントの動作に追加しようとしましたか?

<behavior name="web">
    <webHttp />
</behavior>

(MEXを機能させたい場合は、それも実行してください)

于 2013-04-25T19:12:13.800 に答える
0

OK、ようやく修正しました。これは PEBKAC の悪いケースでした。=/

サービス名に名前空間が含まれていなかったために同じ問題を抱えている人を見たことがあります。

サービスの Azure 実装が間違った名前空間で定義されていたことが判明しました。私はそれを修正し、ほら、今は動作します。

少なくとも、これが他の誰かに役立つことを願っています。

于 2013-04-25T20:15:57.090 に答える