Click here to Skip to main content
15,112,667 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
This is my Code:

WebClient reportClient = new WebClient();
     //String uri = "/ServiceManager.svc/GetReport";
     string uri = "http://xyz.com:4511/LIService.svc/GetState";
     reportClient.DownloadStringCompleted +=new DownloadStringCompletedEventHandler(reportClient_DownloadStringCompleted);
     reportClient.DownloadStringAsync(new Uri(uri));


My web service is now hosted separately

[OperationContract]
[WebInvoke(Method = "GET",
BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "GetState")]
public List<State> GetState()
{
    DBManager dbManager = new DBManager(DataProvider.SqlServer);
    dbManager.ConnectionString = ConfigurationManager.ConnectionStrings["LaborInsightConnectionString"].ConnectionString;
    List<State> stateList = new List<State>();
    try
    {
        dbManager.Open();
        dbManager.ExecuteReader(CommandType.Text, "select Name , FullName  from CanonState where FullName<>'Unknown'");
        while (dbManager.DataReader.Read())
        {
            var rep = new State
            {
                id = dbManager.DataReader[0].ToString(),
                Name = dbManager.DataReader[1].ToString()
            };
            stateList.Add(rep);
        }

    }
    catch (Exception ex)
    {
        throw ex.InnerException;
        //return null;
    }
    finally
    {
        dbManager.Dispose();
    }
    return stateList;
}


When web service is separately hosted, it is not able to consume in my project.

Please help me. Thanks in advance.
Posted
Comments
Sandeep Mewara 14-Mar-11 2:19am
   
what is the error? What does it say when you try to consume it?

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