如何让这个简单的WCF REST客户端工作?

时间:2013-03-22 17:45:45

标签: c# json wcf rest

我尝试从我的应用程序中调用此URI:http://data.mtgox.com/api/1/BTCEUR/ticker?raw

将此代码用作ServiceContract:

[ServiceContract(Namespace = "/api/1")]
public interface ITickerService
{
    //base uri: "http://data.mtgox.com";

    [OperationContract]
    [WebGet(ResponseFormat = WebMessageFormat.Json,
            UriTemplate = "{ident}{currency}/ticker?raw")]
    String GetTicker(String ident, String currency);
}

这个调用代码

BasicHttpBinding myBinding = new BasicHttpBinding();

EndpointAddress mtGoxEndpoint = new EndpointAddress("http://data.mtgox.com/");
ChannelFactory<ITickerService> channelFactory = new ChannelFactory<ITickerService>(myBinding, mtGoxEndpoint);

ITickerService tickerService = channelFactory.CreateChannel();

// Stops here till timeout after 1 min
var result = tickerService.GetTicker("BTC", "EUR");

任何想法可能出错?

Tanks,Tarion

0 个答案:

没有答案