这就造成了当使用HttpWebRequest访问时,不成功就会出现System.Net.WebException: ‘The remote server returned an error: (500) Internal Server Error.’报错(如下图),获取不到结果了。
怎么办呢,这里只能通过获取异常,然后将异常的相应结果返回。
用下面的代码就不论500错误是否发生,都能获取到Web Service返回值的源代码。
//500 error but get the message
HttpWebResponse res;
try
{
res = (HttpWebResponse)webRequest.GetResponse();
}
catch (WebException ex)
{
res = (HttpWebResponse)ex.Response;
}
StreamReader sr = new StreamReader(res.GetResponseStream() ?? throw new InvalidOperationException(), Encoding.UTF8);
var result = sr.ReadToEnd();
除了截图,我还附上一些代码,是通过Where Used Table Field 找到所有tcmcs032.edat的使用清单,逐个检查代码后找到的一个最简单的应用例子。估计能看此文看到这里的人都能看得懂:
function get.sing.tax()
{
select tcmcs032.*
from tcmcs032
where tcmcs032._index1 = {:tcmcs036.ccty, :tcmcs036.cvat}
order by tcmcs032._index1 desc
as set with 1 rows
selectdo
tax.rate = tcmcs032.pvat
selectempty
tax.rate = 0
endselect
}