2017-10-31 14 views
0

wcf Rest Serviceを使用してAngular JSアプリケーションで単一レコードを取得しようとしています。Google Chromeのコンソールウィンドウにチェックインしました。私は、エラー..ここWcfサービスでAngular JSのIdに基づいてシングルレコードを取得できない

Failed to load resource: the server responded with a status of 404 (Not Found) 

がinterfce ..ですここで

 [OperationContract] 
      [WebInvoke(Method = "GET", 
       RequestFormat = WebMessageFormat.Json, 
       ResponseFormat = WebMessageFormat.Json, 
       UriTemplate = "/AccountBalanceCheek")] 
      AccountBalanceRequest AccountBalanceCheek(AccountBalanceRequest accountNumber); 

が実装され、次のです。ここで

public AccountBalanceRequest AccountBalanceCheek(AccountBalanceRequest accountNumber) 
     { 
      using (SqlConnection conn = new SqlConnection(ConnectionString)) 
      { 
       conn.Open(); 

       var cmd = new SqlCommand("SELECT * FROM Current_Account_Details WHERE Account_Number = '" + accountNumber.Account_Number + "'", conn); 


       cmd.CommandType = CommandType.Text; 

       var reader = cmd.ExecuteReader(); 
       //read the result of the execute command. 
       while (reader.Read()) 
       { 
        //assuming that your property is the same as your table schema. refer to your table schema Current_Account_Details 

        accountNumber.Account_Number= reader["Account_Number"].ToString(); 
        accountNumber.Account_Creation_Date = reader["Account_Creation_Date"].ToString(); 

        accountNumber.Account_Type = reader["Account_Type"].ToString(); 
        accountNumber.Branch_Sort_Code = reader["Branch_Sort_Code"].ToString(); 
        accountNumber.Account_Fees = reader["Account_Fees"].ToString(); 
        accountNumber.Account_Balance = reader["Account_Balance"].ToString(); 
        accountNumber.Over_Draft_Limit = reader["Over_Draft_Limit"].ToString(); 
       } 
       return accountNumber; 
      } 
     } 

はここ

var app = angular.module("WebClientModule", []) 
    .controller('Web_Client_Controller', ["$scope", 'myService', function ($scope, myService) { 
    var Id = $scope.Account_Number; 
    $scope.search = function (Id) { 
     var promiseGetSingle = myService.getbyId(Id); 

     promiseGetSingle.then(function (pl) { 
      var res = pl.data; 
      $scope.Account_Number = res.Account_Number; 
      $scope.Account_Creation_Date = res.Account_Creation_Date; 
      $scope.Account_Type = res.Account_Type; 
      $scope.Branch_Sort_Code = res.Branch_Sort_Code; 
      $scope.Account_Fees = res.Account_Fees; 
      $scope.Account_Balance = res.Account_Balance; 
      $scope.Over_Draft_Limit = res.Over_Draft_Limit; 

      // $scope.IsNewRecord = 0; 
     }, 
      function (errorPl) { 
       console.log('failure loading Employee', errorPl); 
      }); 
    } 
    }]); 




app.service("myService", function ($http) { 

    this.getbyId = function (Id) { 
     return $http.get("http://localhost:52098/HalifaxIISService.svc/AccountBalanceCheek" + Id); 
    }; 
    }) 

はhtmlです..私のスクリプトコードです。

@{ 
    Layout = null; 
} 

<!DOCTYPE html> 

<html ng-app="WebClientModule"> 
<head> 
    <meta name="viewport" content="width=device-width" /> 

    <title>AccountBalance</title> 
    <script src="~/Scripts/angular.min.js"></script> 
    <script src="~/RegistrationScript/AccountBalance.js"></script> 

</head> 
<body> 
    <div ng-controller="Web_Client_Controller"> 
     Enter Account_Number: <input type="text" ng-model="Account_Number" /> 
     <input type="button" value="search" ng-click="search(Account_Number)" /> 

      <table id="tblContainer" data-ng-controller="Web_Client_Controller"> 
       <tr> 
        <td> 
         <table style="border: solid 2px Green; padding: 5px;"> 
          <tr style="height: 30px; background-color: skyblue; color: maroon;"> 
           <th></th> 
           <th>Account Number</th> 
           <th>Account Creation Date</th> 
           <th>Account Type</th> 
           <th>Branch Sort Code</th> 
           <th>Account Fees</th> 
           <th>Account Balance</th> 
           <th>Over Draft Limit</th> 

           <th></th> 
           <th></th> 
          </tr> 
          <tbody data-ng-repeat="user in Users"> 
           <tr> 
            <td></td> 
            <td><span>{{user.Account_Number}}</span></td> 
            <td><span>{{user.Account_Creation_Date}}</span></td> 
            <td><span>{{user.Account_Type}}</span></td> 
            <td><span>{{user.Branch_Sort_Code}}</span></td> 

            <td><span>{{user.Account_Fees}}</span></td> 
            <td><span>{{user.Account_Balance}}</span></td> 
            <td><span>{{user.Over_Draft_Limit}}</span></td> 
            <td> 

           </tr> 
          </tbody> 
         </table> 
        </td> 
       </tr> 
       <tr> 
        <td></td> 
       </tr> 
       <tr> 
        <td> 

         <div style="color: red;">{{Message}}</div> 

        </td> 
       </tr> 
      </table> 
     </div> 
     </body> 


</html> 

ハーズは、グーグルクロームでappication結果..です

click here to see the oput put

答えて

1

あなたが404泉ではないエラーが出る場合には、何かがあなたのエンドポイントアドレスが間違っていることを意味します。まず、フィドラーまたはポストマンでサービスを利用し、サービスが正常にロードされるようにしてください。あなたのクライアント側のコードが動作することを確認するためにあなたの角度の要求をトレースしてください。

+0

はい、あなたは正しいです。私がlocalhost://halifaxService.svc/AccountBalamceRequestと入力したとき。それから終点を見つけることができません。私はなぜ思っていますか? – Mohammad

関連する問題