Web服务休息错误http 400

时间:2014-04-24 12:16:48

标签: c# rest windows-mobile

我有一个仅用于数据的WebService。

使用服务:

 [WebGet(UriTemplate = "maq/?v={v}",
            RequestFormat = WebMessageFormat.Xml,
            ResponseFormat = WebMessageFormat.Xml)]
        [OperationContract]
        List<VoltaPDA> GetAllta(int v);

它完美无缺;

在同一个webService中使用此函数:

[WebGet(UriTemplate = "ped/?T={ti}&V={Vo}",
            RequestFormat = WebMessageFormat.Xml,
            ResponseFormat = WebMessageFormat.Xml)]
        [OperationContract]
        List<Pedido> GetSub(string ti,string Vo);

我得到了error HTTP 400好奇,通过浏览器直接测试都可以正常工作,当我在Windows Mobile 6.5 application上使用它时,第二个函数返回HTTP 400 error

你能想象它会是什么吗?

两者都访问相同的数据库Sql Server 2012以及WebService中托管的IIS 8.5

webConfig:

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="BD_S_V10ConnectionString" connectionString="Data Source=NUNO-PC;Initial Catalog=BD_S_V10;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
  <globalization culture="pt-PT" uiCulture="pt-PT" />
  </system.web>
  <system.serviceModel>
    <!-- REST -->
    <services>
      <service name="WcfServicePedido_v7.ServicePedido">
        <endpoint name="RestEndPoint" contract="WcfServicePedido_v7.IServicePedido" binding="webHttpBinding" address="" behaviorConfiguration="restBehavior"/>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="restBehavior">
          <webHttp helpEnabled="true"/>
        </behavior>
      </endpointBehaviors>
      <!-- REST -->
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="Traces.svclog" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId"/>
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
</configuration>

1 个答案:

答案 0 :(得分:0)

通常会从客户端返回Mime-Type不匹配和格式错误的请求(正文和某些时间网址)的默认400响应。

在这种情况下,我建议您检查第二个请求中移动应用程序发送的Content-Type标头,以确保其类似text/xml