Consuming Web Service HTTP Post

血红的双手。 提交于 2019-12-06 07:24:55

This is a very weird use of a custom service client to send x-www-form-urlencoded data, I think this is a bit ambitious to try as ServiceStack's ServiceClients are meant to send/receive the same Content-type. Where as even though your class is called JsonCustomClient it's no longer a JSON client since you've overrided the the Format property.

The issue your having is likely using the StreamWriter in a using statement which would close the underlying stream. Also I expect you calling the base method to be an error since you're going to have an illegal mix of Url-Encoded + JSON content-type on the wire.

Personally I would steer clear of the ServiceClients and just use any standard HTTP Client, e.g. ServiceStack has some extensions to WebRequest that wraps the usual boilerplate required in making HTTP calls with .NET, e.g:

var json = "{0}/SeizureAPILogs".Fmt(URI)
           .PostToUrl("jsonRequest=string", ContentType.FormUrlEncoded);

var logsDtoResponse = json.FromJson<LogsDTOResponse>();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!