处理WCF服务中的小数(。),哈希(#)和速率(@)符号 [英] Handle decimals (.), Hash (#) and at the rate (@) symbol in WCF service
本文介绍了处理WCF服务中的小数(。),哈希(#)和速率(@)符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用WCF服务来插入,选择和&将数据更新到sql server DB tables.This服务将从iPhone / Android应用程序调用。
每当有小数点(。),哈希(#)和at URI中的速率(@)符号,WCF停止工作并给我服务器错误?
请帮我解决问题。
提前致谢。
I am working with WCF service to Insert, Select, & Update data to sql server DB tables.This service will be called from iPhone/Android app.
Whenever there is a decimals (.), Hash (#) and at the rate (@) symbol in URI, WCF stops working and give me server error?
Please help me out to resolve the issus.
Thanks in advance.
public interface ICustomers
{
[OperationContract]
//attribute for returning JSON format
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
RequestFormat=WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "Register/{name}/{address}/{city}/{pincode}/{email}/{mobile}/{password}/{loggedvia}")]
//method
string RegisterCustomer(string name, string address, string city, string pincode, string email, string mobile, string password, string loggedvia);
public string RegisterCustomer(string name, string address, string city, string pincode, string email, string mobile, string password, string loggedvia)
{
try
{
conRegisterCustomer = new SqlConnection(ConfigurationManager.AppSettings["Medico"]);
cmdRegisterCustomer = new SqlCommand("HMC_API_Insert_Customer", conRegisterCustomer);
conRegisterCustomer.Open();
// conRegisterCustomer.BeginTransaction("Customer");
cmdRegisterCustomer.CommandType = CommandType.StoredProcedure;
//cmdRegisterCustomer.Connection.BeginTransaction();
//cmdRegisterCustomer.Connection.
//cmdRegisterCustomer.Parameters.AddWithValue("@CustId", objRegisterCustomer.pCustId);
cmdRegisterCustomer.Parameters.AddWithValue("@Name", name);
cmdRegisterCustomer.Parameters.AddWithValue("@Address", address);
cmdRegisterCustomer.Parameters.AddWithValue("@City", city);
cmdRegisterCustomer.Parameters.AddWithValue("@PinCode", pincode);
cmdRegisterCustomer.Parameters.AddWithValue("@Email", email);
cmdRegisterCustomer.Parameters.AddWithValue("@Mobile", mobile);
cmdRegisterCustomer.Parameters.AddWithValue("@Password", password);
cmdRegisterCustomer.Parameters.AddWithValue("@LoggedVia", loggedvia);
cmdRegisterCustomer.Parameters.AddWithValue("@Createdate", System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss"));
SqlParameter parmOUT = new SqlParameter("@CustId", SqlDbType.Int);
parmOUT.Direction = ParameterDirection.Output;
cmdRegisterCustomer.Parameters.Add(parmOUT);
cmdRegisterCustomer.ExecuteNonQuery();
rows = (int)cmdRegisterCustomer.Parameters["@CustId"].Value;
// return cmdSubscription.ExecuteNonQuery();
//rows = cmdRegisterCustomer.ExecuteNonQuery();
if (rows == 0)
{
return "fail";
}
else
{
return "success";
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
conRegisterCustomer.Close();
conRegisterCustomer.Dispose();
}
}
}
推荐答案
尝试编码 <调用它时code> URL 。
这篇关于处理WCF服务中的小数(。),哈希(#)和速率(@)符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文