細かい作業を受けるが、POSTを使用してIDによるGETまたはPUTはvwHealthcareを実装IDataServiceように、エラー404htmlページのデータサービスとしてのWCF。 jQuery ajax関数
WCF DataService.svc
公開機能GetHealthcare(文字列としてByVal区分)を返しています。新vwHealthcareとしてGetHealthcare 薄暗いnSubject
Dim context As DataClasses1DataContext = New DataClasses1DataContext()
'Check if exists
Dim res = From b In context.vwHealthcares Where b.CategoryId = CategoryId
Select b
Dim uList As List(Of vwHealthcare) = res.ToList()
Return res
End Function
IDataService
<WebInvoke(Method:="POST", ResponseFormat:=WebMessageFormat.Json, UriTemplate:="GetHealthcareByCategoryId/{CategoryId}")>
<OperationContract()>
Function GetHealthcare(ByVal CategoryId As String) As vwHealthcare
私のクライアントHTML:
// Urls to access the WCF Rest service methods var urlsource ; urlsource = "http://localhost/ehealthservice/DataService.svc/"; var varType; var varUrl; var method; var varData; var varContentType; var varDataType; var varProcessData; //Generic function to call AXMX/WCF Service function CallServiceC() { debugger; var categoryid = getQueryStringValue('CategoryId'); var oData; debugger; $.ajax({ cache: false, type: varType, //GET or POST or PUT or DELETE verb url: varUrl, // Location of the service data: oData, //Data sent to server contentType: varContentType, // content type sent to server crossDomain: true, dataType: varDataType, timeout: 2000, success: function (msg) {//On Successfull service call debugger; // I want to get here return html; } }, error: ServiceFailedC// When Service call fails }); } function ServiceFailedC(result) { debugger; var myJSON = JSON.stringify(result); alert('Service call failed: ' + result.status + '' + result.statusText); varType = null; varUrl = null; varData = null; varContentType = null; varDataType = null; varProcessData = null; } function GetHealthcareByCategory() { debugger; varType = "POST"; varUrl = urlsource + "GetHealthcareByCategoryId/1"; varContentType = "application/json; charset=utf-8"; varDataType = "jsonp"; varProcessData = false; method = "GetHealthcare"; CallServiceC(); } function getQueryStringValue(key) { debugger; return unescape(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + escape(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1")); }; $(document).ready( function() { GetHealthcareByCategory(); } );
注:私はまだ同じ404エラーを多くのアプローチを試してみました 。私はそのフォルダに対しても読み取り/書き込み許可を有効にしています。このサンプルは、リンクenter link description hereのPranyaの例に従っていますが、私はまだエラー404を取得しています。