Click here to Skip to main content
15,909,039 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i had maked a webservice in which getleger function is maked like this :
C#
public List<datalist7> getleger(string accno, string fromdate, string todate)
{
   SqlConnection con = new SqlConnection(@"Data Source=saba-PC;Initial Catalog=bcounts;Integrated Security=True");
   con.Open();
   SqlCommand cmd = new SqlCommand("select gt.Value_Date,gt.Voucher_no+'-'+gr.VchrType as voucher,gt.Acct_Nirration,gr.InstrumentNo,gt.Dr_Amount,gt.Cr_Amount  from gl_transaction gt, Gl_Ref gr where gt.Accountno = '" + accno + "'  and gt.Voucher_No=gr.Voucher_no  and gt.Value_Date between '" + fromdate + "' and '" + todate + "'", con);
   SqlDataReader rdr = cmd.ExecuteReader();
   decimal crsum = 0;
   decimal drsum = 0;
   decimal balance = 0;
   List<datalist7> data = new List<datalist7>();
   if (rdr.HasRows)
   {
      while (rdr.Read())
      {
         if (rdr.GetDecimal(4) > 0)
         {
            balance = balance + rdr.GetDecimal(4);
            drsum += rdr.GetDecimal(4);
            data.Add(new datalist7(rdr.GetDateTime(0).ToShortDateString(), rdr.GetString(1), rdr.GetString(2), rdr.GetString(3), rdr.GetDecimal(4).ToString(), "-", balance.ToString()));
         }
         else
         {
            balance = balance - rdr.GetDecimal(5);
            crsum += rdr.GetDecimal(5);
            data.Add(new datalist7(rdr.GetDateTime(0).ToShortDateString(), rdr.GetString(1), rdr.GetString(2), rdr.GetString(3), "-", rdr.GetDecimal(5).ToString(), balance.ToString()));
         }
      }
      data.Add(new datalist7("-", "-", "-", "-", drsum.ToString(), crsum.ToString(), "-"));
   }

   con.Close();
   return data;
}


and in Service1.cs file

XML
[OperationContract]
   [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json,
      BodyStyle = WebMessageBodyStyle.Wrapped,
      UriTemplate = "getleger/accno={accno}&fromdate={fromdate}&todate={todate}")]
      List<datalist7> getleger(string accno, string fromdate, string todate);


but whenever i called this method on browser like this
http://localhost:49609/ipadservice.svc/getleger/0010010010006/2013-02-01/2014-02-01

it shows :
Endpoint not found. Please see the service help page for constructing valid requests to the service.

what was the matter?
Posted
Updated 18-May-14 7:02am
v3

1 solution

you are not comply with your 'UriTemplate'. moreover, it is ill-formed.
change it into:
UriTemplate = "getleger?accno={accno}&fromdate={fromdate}&todate={todate}"


and I advice to change your thinking-way from soa to objects if you use restful services. getleger is like a method name but with 'REST' you get objects or change states of objects.

better to have uri template as:

UriTemplate = "leger?accno={accno}&fromdate={fromdate}&todate={todate}"

you call would be:
http://localhost:49609/ipadservice.svc/leger?accno=123&fromdate=20030101&todate=20030102


and read it as:
'give me legers having accno={accno} and between dates 'fromdate' and 'todate''

more info:
UriTemplate[^]
REST[^]
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900