0

我创建了两个 WCF Web 服务。第一个服务是返回 JSON 字符串的获取服务,第二个服务是接受此 JSON 字符串作为输入并将这些数据存储在数据库中的后期服务。

这两项服务在本地工作正常,但是当我在服务器上上传我的代码时,第一个服务继续正常工作,但第二个服务,即发布服务,返回一个错误:

错误 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

The difference could be the security settings, that you have no security locally but windows authentication on the server.

A combination of IE and NTLM would work for a http get, but give a bad request for a http POST.

Se this link: 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 回答