0

2 つの WCF Web サービスを作成しました。1 番目のサービスは JSON 文字列を返す取得サービスであり、2 番目のサービスはこの JSON 文字列を入力として受け入れ、それらのデータをデータベースに格納するポスト サービスです。

両方のサービスはローカルで正常に動作しますが、サーバーにコードをアップロードすると、最初のサービスは引き続き正常に動作しますが、2 番目のサービス、つまりポスト サービスはエラーを返します。

エラー 400 不正な要求。

私の知る限り、Web.config ファイルに何かが欠けています。

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <!--
    <add name="Conn" connectionString="Data Source=*.*.*.*;Initial Catalog=*;User ID=*;Password=*" providerName="System.Data.SqlClient" />
    <add name="connString" connectionString="Data Source=*.*.*.*;Initial Catalog=*;User ID=*;Password=*" providerName="System.Data.SqlClient" />
    -->
    <add name="Conn" connectionString="Data Source=*;Initial Catalog=SunshineDB;Integrated Security=True"/>
  </connectionStrings>
  <system.serviceModel>
    <bindings>
  <webHttpBinding>
    <binding name="NetTcpBinding_IClaims" 
                       closeTimeout="00:01:00" 
                       openTimeout="00:01:00" 
                       receiveTimeout="00:10:00" 
                       sendTimeout="00:01:00" 
                       transferMode="Buffered" 
                       hostNameComparisonMode="StrongWildcard" 
                       maxBufferPoolSize="2147483647" 
                       maxBufferSize="2147483647" 
                       maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" 
                        maxStringContentLength="2147483647" 
                        maxArrayLength="2147483647" 
                        maxBytesPerRead="2147483647" 
                        maxNameTableCharCount="16384"/>
          <security mode="None">
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </webHttpBinding>
      <wsHttpBinding>
        <binding name="wsBufferedHttpsBinding" 
                 messageEncoding="Mtom"
                 maxReceivedMessageSize="11534336" 
                 maxBufferPoolSize="524288"
                 sendTimeout="00:05:00" 
                 receiveTimeout="00:05:00" 
                 openTimeout="00:05:00" 
                 closeTimeout="00:05:00" >
          <readerQuotas maxDepth="64" 
                        maxStringContentLength="11534336" 
                        maxArrayLength="11534336"
                        maxBytesPerRead="11534336" 
                        maxNameTableCharCount="16384" />
        </binding>
      </wsHttpBinding>
      <customBinding>
        <binding name="basicConfig">
          <binaryMessageEncoding/>
          <httpTransport transferMode="Streamed" 
                         maxReceivedMessageSize="67108864"/>
        </binding>
      </customBinding>
    </bindings>
    <services>
      <service name="SunShineServices.Service1">
        <endpoint address="" 
                  binding="webHttpBinding" 
                  behaviorConfiguration="EndBehave"
                  contract="SunShineServices.ISunShineServices">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="EndBehave">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>
4

1 に答える 1

0

違いは、セキュリティ設定である可能性があります。ローカルにはセキュリティがありませんが、サーバーには Windows 認証があります。

IE と NTLM の組み合わせは、http get では機能しますが、http POST では不適切な要求を出します。

このリンクを参照してください: http://blogs.msdn.com/b/asiatech/archive/2012/01/30/400-bad-request-when-posting-webservice-or-wcf-request-from-ie.aspx

于 2013-03-02T10:46:22.287 に答える