简体   繁体   中英

Retrieving online data with a wcf service

I'm facing a little problem, and I hope that you will have a solution. I'm using a wcf service to retrieve online data (from yahoo finance). This service calls an API which connect to yahoo in order to retrieve the data I need. However, when I call the API, I get the error

An exception occurred during a WebClient request.

I'm calling this service from console application.

I hope that you can help me with this issue.

== Here is the code

/* wcf service Interface */
 [ServiceContract]
public interface IService1
{

    [OperationContract]
    string GetData(int value);


    // TODO: Add your service operations here
}

/* the service calls this function which belongs to another c# project */
public String updateDataBase()
{
    DBHandler handler = new DBHandler();
    /* Goes online et retrieve the data, when its called, the exception occurs */
    handler.updateData();
    return "success";

}

I solved my problem by running visual studio as Administrator.

Thank you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM