做了一個服務,它在下面的框中配置,當參數不匹配時拋出一個404? 在這種情況下,參數是一個複雜的類型,每次調用SearchJson方法返回一個404 ...... (它甚至允許與WebInvoke選項並沒有UriTemplate?)帶webHttpBinding的WCF服務; 404錯誤
該服務啓動並運行(我可以調用Testpage「生成你的客戶.. WSDL?」 -stuff)
服務方法被配置爲:
[OperationContract]
[FaultContract(typeof(Exception))]
[WebInvoke(ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.WrappedRequest,
RequestFormat = WebMessageFormat.Json)]
SearchResponse SearchJson(SearchRequest req);
任何想法如何解決這個問題?
btw。這是我用於測試...無論我更改什麼參數,返回404 ...我只能觸發不同的行爲時,我將WebInvoke更改爲WebGet並使用簡單類型作爲參數(如字符串) ...然後我得到一個405
WebRequest req = HttpWebRequest.Create("http://localhost:8800/SearchService/SearchJson");
req.Method = "POST";
req.ContentType = "application/json";
req.ContentLength = 354;
WebResponse resp = req.GetResponse();
這裏是在配置:
<service name="SearchEngine.SearchService" behaviorConfiguration="HTTPGetBehavior">
<endpoint address="SearchEngine.SearchService"
behaviorConfiguration="ajaxBehavior"
binding="webHttpBinding"
contract="SearchEngine.ISearchInterface" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8800/SearchService" />
</baseAddresses>
</host>
</service>
的WebServiceHost將盡一切花哨的REST技巧需要這個。您將需要使用常規ServiceHost的WebServiceHost instaead(期望SOAP格式的消息) – 2009-07-10 15:46:06