Esempio n. 1
0
        async Task <XmlRpcResponse> ReadResponseAsync(
            XmlRpcRequest req,
            HttpResponseMessage webResp)
        {
            //HttpWebResponse httpResp = (HttpWebResponse)webResp;
            if (!webResp.IsSuccessStatusCode)
            {
                // status 400 is used for errors caused by the client
                // status 500 is used for server errors (not server application
                // errors which are returned as fault responses)

                throw new XmlRpcServerException(webResp.StatusCode.ToString());
            }
            var deserializer = new XmlRpcResponseDeserializer();

            var stream = await webResp.Content.ReadAsInputStreamAsync();


            deserializer.NonStandard = _nonStandard;
            Type retType = req.mi.ReturnType;

            if (retType.IsConstructedGenericType)
            {
                retType = retType.GenericTypeArguments[0];
            }
            XmlRpcResponse xmlRpcResp
                = deserializer.DeserializeResponse(stream.AsStreamForRead(), retType);

            return(xmlRpcResp);
        }
Esempio n. 2
0
        XmlRpcResponse ReadResponse(
            XmlRpcRequest req,
            WebResponse webResp,
            Stream respStm)
        {
            HttpWebResponse httpResp = (HttpWebResponse)webResp;

            if (httpResp.StatusCode != global::System.Net.HttpStatusCode.OK)
            {
                // status 400 is used for errors caused by the client
                // status 500 is used for server errors (not server application
                // errors which are returned as fault responses)
                if (httpResp.StatusCode == global::System.Net.HttpStatusCode.BadRequest)
                {
                    throw new XmlRpcException(httpResp.StatusDescription);
                }
                else
                {
                    throw new XmlRpcServerException(httpResp.StatusDescription);
                }
            }
            var deserializer = new XmlRpcResponseDeserializer();

            deserializer.NonStandard = _nonStandard;
            Type           retType = req.mi.ReturnType;
            XmlRpcResponse xmlRpcResp
                = deserializer.DeserializeResponse(respStm, req.ReturnType);

            return(xmlRpcResp);
        }