У меня есть 2 метода, приведенных ниже, в классе метод Login работает нормально, извлекает и устанавливает токен сеанса, но для того, чтобы я использовал GetEvents (), я должен отправить sessionToken в запросе для GetEvents ( ).
Но в 4-й строке кода (исключая Комментарии и пробелы) функции getEvents () я получаю ошибку: ссылка на объект не установлена на экземпляр объекта.
The Entire Source can be downloaded here: (Copy and Paste into your browser)
http://www.theebookzone.co.uk/betfairui.zip
Есть идеи, что я делаю не так?
Любая помощь приветствуется, даже если она не имеет прямого отношения к этому вопросу.
public static string SessionToken = ""; // Set by Login();
static LoginResp Login()
{
// Make a new BFGS instance
BFGlobal = new BFGlobalService.BFGlobalService();
// Set up the request in [req]
LoginReq req = new LoginReq();
req.username = username;
req.password = password;
req.productId = productId;
req.vendorSoftwareId = softwareId;
// Set up the response in [resp]
// Execute the call, and pass in the request
LoginResp resp = BFGlobal.login(req);
// Sets our public variable above to the recieved sessionToken
SessionToken = resp.header.sessionToken;
// return [resp] - which is the response from the call
return resp;
}
public Array GetEvents()
{
// This will set the sessionToken declared at the top.
LoginToBetfair();
// Make a new instance of the web service
BFGlobal = new BFGlobalService.BFGlobalService();
// Load up the request
GetEventsReq req = new GetEventsReq();
// Error Line Below:
req.header.sessionToken = SessionToken; // <--- Here is where I get the error
// Error Above Line: Object reference not set to an instance of an object.
GetEventsResp resp = BFGlobal.getEvents(req);
Array marketItems = resp.marketItems;
return marketItems;
}