weixin_39059345
weixin_39059345
2020-08-26 14:53

C# WebService本地调试正常,放到IIS服务器上就传空值回来!

  • c#
  • asp.net
  • visual studio

Web服务是引用RestSharp访问的客户数据,代码如下:

[WebMethod]
        public string Get_DateCode(string Query_snNo)
        {
            try
            {
                var client = new RestClient("http://***********");
                //client.Timeout = -1;
                var request = new RestRequest(Method.POST);
                request.Timeout = 10000;
                request.AddHeader("X-HW-ID", "***************");
                request.AddHeader("X-HW-APPKEY", "*************");
                request.AddHeader("Content-Type", "application/json");
                request.AddParameter("application/json", "******", ParameterType.RequestBody);
                IRestResponse response = client.Execute(request);
                return response.StatusCode + response.Content; //返回的结果
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }

        }

在本机调试传回的信息是

<?xml version="1.0" encoding="ISO-8859-1"?>
<string xmlns="http://tempuri.org/">{OK"msg":"SUCCESS"</string>

在IIS上发布后是可以正常运行的,但是传回的是

<?xml version="1.0" encoding="ISO-8859-1"?>
<string xmlns="http://tempuri.org/">0</string>

第一次用RestSharp,求大佬给看下哪里有问题

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答