1

I am trying to call a 3rd party web service

Their REST API uses the following URL style.

http://www.VoiceBase.com/services?version=1.0&apikey=your-apikey&password=secret&action=list&status=processing

All of their service calls go to the same /services

How do I create a class so the following would work?

var client = new JsonServiceClient("http://www.voicebase.com");
var response = client.Get<ResponseVoiceBaseListClass>(new VoiceBaseListClass());

Additional classes I have created but I am not quite there yet

    public class VoiceBaseBaseClass
    {
        public string version { get; set; }
        public string apikey { get; set; }
        public string password { get; set; }

        public VoiceBaseBaseClass()
        {
            this.version = "1.0";
            this.apikey = "API";
            this.password = "password";
        }
    }

    public class VoiceBaseListClass : VoiceBaseBaseClass, IReturn<ResponseVoiceBaseListClass>
    {
        public string action { get; set; }
        public string status { get; set; }

        public VoiceBaseListClass()
            : base()
        {
            this.action = "list";
            this.status = "processing";
        }
    }


    public class ResponseVoiceBaseListClass
    {
        public string requestStatus { get; set; }
        public string statusMessage { get; set; }
        public string fileStatus { get; set; }
        public List<string> mediaIds { get; set; }

        public ResponseVoiceBaseListClass()
        {
            this.mediaIds = new List<string>();
        }
    }

Using the above classes the call that goes to the server is

/json/syncreply/VoiceBaseListClass?action=list&status=processing&version=1.0&apikey=API&Password=password

Is there a way I can force the service stack client to go to the

 /Services

instead of

/json/syncreply/VoiceBaseListClass
4

1 回答 1

1

我找到了一种方法来做到这一点,它对我很有用。

    [RestService("/services", "GET")]
    public class VoiceBaseListClass : VoiceBaseBaseClass, IReturn<ResponseVoiceBaseListClass>
    {
    }

虽然这是一个已弃用的属性 - 新属性称为 Route

https://github.com/ServiceStack/ServiceStack/wiki/Release-Notes

克里斯

于 2013-08-18T21:08:26.370 回答