Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
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.

[EDIT - OPs code from comment]
C#
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();
        }
    }
}
Posted
Updated 6-May-14 1:26am
v2
Comments
DamithSL 6-May-14 5:10am    
update the question with your code
Lalit Kumar Jain 6-May-14 6:11am    
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();


}
}
DamithSL 6-May-14 6:14am    
how you call this web service?
Lalit Kumar Jain 6-May-14 6:27am    
http://localhost:3591/Customers.svc/Register/Lalit /Aerodrome road/Indore/452005/jainlalit77%40gmail%2Ecom/919926572400/password%2380JaiHoMataji/Google%20Account
Lalit Kumar Jain 6-May-14 6:30am    
This is using fiddler i am testing on my local pc.

1 solution

Try Encoding the URL while calling it.
 
Share this answer
 

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