无法从REST CLIENT PHP或Mozilla Rest Client访问WCF REST API POST METHOD

时间:2013-02-05 19:05:50

标签: php wcf rest post service

我使用WCF创建Web服务,但无法从PHP或Mozilla Client Rest API访问POST方法。我尝试更改bodyStyle并且不要声明它,但我无法完成它。我总是得到400 BAD REQUEST。 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>

                                      

1 个答案:

答案 0 :(得分:0)

我最终在MVC4上改为Web Api,没有更多问题。

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