0

我正在尝试连接到以下 betfair.com 网络服务。 https://api.betfair.com/global/v3/BFGlobalService.wsdl
基本上我只是想登录并在控制台窗口中显示这些信息。

我用 PHP 做到了这一点,这很容易,但我是 C# 新手,开始时遇到了麻烦。
基本上,我想登录并在屏幕上显示从 Web 服务接收到的会话令牌。

我在 Visual Studio .net 2010 中添加了对解决方案的 Web 服务引用。在 PHP 中,我们只需向 Web 服务发出一个请求,它会将数据作为对象返回。但似乎在 C# 中,我必须进行 2 个调用,请求和响应?这是正确的吗?

抱歉,我是 c# 的新手,但我看到了该语言的巨大潜力,我真的需要一些关于如何进行的基本指导。

目前,我已将 Web 服务添加到我的解决方案中,为了登录和接收会话令牌,我必须做的最基本的事情是什么。

有关必发网络服务的更多信息,请访问:
http ://bdp.betfair.com/index.php?option=com_weblinks&catid=59&Itemid=113

我尝试查看通过 betfair 提供的示例应用程序,但它们非常复杂,我只想要最简单的方法来使用 Web 服务并登录以检索会话令牌。

谢谢

编辑
我正在尝试这样的事情。

class Program
{
    public static string username = "username";
    public static string password = "password";
    public static int softwareId = 82;
    public static int productId = 0;


    private static BFGlobalService m_globalService;

    static void Main(string[] args)
    {
        m_globalService = new BFGlobalService();

    }

    static void Login()
    {
        LoginReq req = new LoginReq();
        req.username = username;
        req.password = password;
        req.productId = productId;
        req.vendorSoftwareId=softwareId;

        LoginResp resp = m_globalService.login(req);

        Console.WriteLine(resp.minorErrorCode);
        Console.ReadKey();
    }
}

但我是菜鸟,所以我什至不知道这是否正确!!

任何能让我站起来的帮助都会很棒!!,如果有什么复杂的话,再加上一个简单的解释。

谢谢!!

编辑:解决方案 我不得不在最后替换这 4 行。

        string st = resp.errorCode.ToString();
        string sessTok = resp.header.sessionToken;

        Console.WriteLine(st + " " + sessTok);
        Console.ReadKey();
4

2 回答 2

1

您可能想下载此应用程序。 http://forum.bdp.betfair.com/attachment.php?s=18f39758fa8c2e850b27cf2d524903ed&attachmentid=20&d=1235565908

它是来自 Betfair 的 C# 参考实现。

这是一个非常好的基础。它具有登录、异步调用实现和不同市场的导航以及如何下注。我自己扩展它真的非常好

于 2011-07-05T22:57:40.240 回答
0

You're never calling your Login method. Try this:

static void Main(string[] args)
{
    m_globalService = new BFGlobalService();

    Login(); // calling your login method here...
}

Also: I'm not familiar with that API but I bet you're missing an initialization call between creating the BFGlobalService object and calling its Login method.

Here are a few pointers to get going with C#:

  • Make use of properties rather than public variables
  • Use try/catch exception handling on your web service calls
  • Try to not do too much work in your Main function. (I know you're just getting started but it's good to practice doing things the right way.) You should have a separate class that Main instantiates and invokes to initiate your web service interaction.
于 2011-06-19T15:24:13.720 回答