【问题标题】:WCF REST API POST METHOD can´t be access from REST CLIENT PHP or Mozilla Rest Client无法从 REST CLIENT PHP 或 Mozilla Rest Client 访问 WCF REST API POST METHOD
【发布时间】:2013-02-05 19:05:49
【问题描述】:

我使用 WCF 创建 Web 服务,但无法从 PHP 或 Mozilla Client Rest API 访问 POST 方法。我尝试更改 bodyStyle 并且不声明它,但我无法完成它。我总是收到 400 错误请求。 GET 方法正在工作。这是我的定义:

[OperationContract]
        [WebInvoke(Method = "POST",
            UriTemplate = "/InsertMember",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped)]
        InsertMemberResponse InsertMember(string city, string address, string state, string zipcode, string country_code, string email, string firtname, string lastname, string password, string national_document_id, string phone, string restaurant_id, string birthday,bool email_checked, bool want_adverts, bool want_notifications, bool want_offers, bool want_thidparty_offers, bool want_newletter, string company_name,string auth );

我的服务模式:

<system.serviceModel>
<services>
  <service name="Mellizos.Fidelidad.Services.RestService">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8733/Design_Time_Addresses/Mellizos.Fidelidad.Services/Service1/" />
      </baseAddresses>
    </host>
    <!-- Service Endpoints -->
    <!-- Unless fully qualified, address is relative to base address supplied above -->
    <endpoint address="" binding="basicHttpBinding" contract="Mellizos.Fidelidad.Services.IRestService">
      <!-- 
          Upon deployment, the following identity element should be removed or replaced to reflect the 
          identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
          automatically.
      -->
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <!-- Metadata Endpoints -->
    <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
    <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <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="False" />
    </behavior>
  </serviceBehaviors>
</behaviors>

【问题讨论】:

    标签: php wcf rest post service


    【解决方案1】:

    我终于换成MVC4上的Web Api,就没有问题了。

    最后我得到了一个理论解释,即在 WCF 中有一个使用协议的协商解决了所有问题。

    【讨论】:

      猜你喜欢
      • 2023-04-04
      • 1970-01-01
      • 2014-08-29
      • 2016-06-26
      • 2016-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多