2013-08-01 63 views
0

突然我收到一個錯誤'Method not allowed。'。當從一個HTML表單調用WCF REST POST服務時(如前所述,它在開發,UAT,生產環境中工作較早,但現在失敗)。WCF REST POST服務 - 當從HTML調用時不允許使用方法

什麼可能導致此問題?以及可能的修復方法是什麼?

<form action="http://localhost:8750/MyService/MyEmailService/RecordResponse" method="post" runat="server"> 
    <div align="left"> 
     <input type="hidden" name="userid" value="abc"> 
     <input type="hidden" name="itemid" value="625"> 
     <select name="response"> 
      <option value="Approved">Approve</option> 
      <option value="Rejected">Reject</option> 
     </select> 
     <textarea cols="40" rows="5" name="comment">Add comments here</textarea> 
     <input type="Submit" value="Submit"> 
    </div> 
</form> 

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] 
public class MyEmailService: IMyEmailService, ISessionAwareService 
{ 
    [OperationContract] 
    [WebInvoke(UriTemplate = "/RecordResponse", Method = "POST")] 
    public void RecordResponse(Stream stream) 
    { 
     // My business logic 
    } 
} 

的配置如下:

<endpointBehaviors> 
    <behavior name="webby"> 
     <webHttp helpEnabled="true"/> 
    </behavior> 

    <service name="CTRL.Server.CommandHandlerService.EmailHandlerService"> 
    <endpoint address="http://localhost:8750/MyService/MyEmailService" 
       binding="webHttpBinding" 
       contract="MyService.ServiceContracts.IEmailService" 
       behaviorConfiguration="webby"/> 

    <webHttpBinding> 
    <binding name="secure"> 
     <security mode="Transport"> 
     <transport clientCredentialType="Basic" /> 
     </security> 
    </binding> 
    </webHttpBinding> 

回答

0

好吧,這裏是一個背景下,我們生成電子郵件程序與HTML表單,其行動呼籲HTML表單提交的WCF REST服務

電子郵件客戶端是用戶用來閱讀電子郵件的前景。

有一些基礎設施升級和提交HTML表單不知何故POST請求WCF沒有得到正確生成。

要解決此問題,我們將WCF服務從POST修改爲GET,編寫了一個Javascript方法來獲取表單數據,並通過包含WCF REST服務URI中的HTML表單數據來調用WCF服務。

相關問題