0

Web アプリケーションを用意します。2 つの wcf サービスを実行し、別のサービスのクライアントです。1 つの wcf サービスは正常に動作し、もう 1 つは開発サーバーでは動作しませんが、ローカルでは動作します。エラーは「応答メッセージのコンテンツ タイプ 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 を入力するとサービス ページが表示され、URL に wsdl を追加すると wsdl が表示されます。

これに対して2日間頭を悩ませてきましたが、問題を見つけることができません。

どんな助けでも大歓迎です

したがって、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

4

3 に答える 3

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>
于 2012-11-06T20:32:05.127 に答える
0

同じサービス コントラクトを使用して 2 つの異なるサービスを構成しようとしているようです。実際にそれを行いたい場合は、同じサービス内の異なるエンドポイントに対して異なるアドレス値を定義するだけですが、それはおそらくあまり役​​に立ちません。

モバイル サービスが別のコントラクトを公開する場合、コントラクトごとに 1 つずつ、2 つの異なるサービス構成が必要です。この場合、company.eShopWorld.Wcf.eShopWorldWCFServiceサービス要素を複製contractし、モバイル サービスの正しい .NET 名前空間とインターフェイス タイプを持つように属性を変更します。また、サービスごとに個別の *.svc ファイルが必要になります。2 つのサービスのデフォルト アドレスは次のようになると思います。

http://HostName/service.svc

http://HostName/mobileservice.svc
于 2012-11-06T20:32:11.593 に答える
-1

そのため、問題はサービス名をすべて小文字に変換するルールであることが判明しました。VS デバッグでは問題が発生しませんでしたが、IIS では問題が発生しました

于 2012-11-29T20:48:25.810 に答える