使用C#验证Inspiremetadata [英] validate inspiremetadata using c#

查看:85
本文介绍了使用C#验证Inspiremetadata的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我已经使用以下方法发送文件以验证url,但是我没有得到任何响应,并且我的浏览器处于连接阶段,我的代码如下,请告诉我如何解决它

我的代码如下

< pre lang ="c#">
字符串url ="http://www.inspire-geoportal.eu/INSPIREValidatorService/resources/validation/inspire";
HttpWebRequest webRequest = WebRequest.Create(url)作为HttpWebRequest;
webRequest.Headers.Clear();
webRequest.Headers.Add("Authorization","text/html");
webRequest.Method ="POST";
webRequest.PreAuthenticate = true;
webRequest.ContentType ="application/xml";
webRequest.Credentials = CredentialCache.DefaultNetworkCredentials;//.DefaultCredentials;
webRequest.UserAgent ="Mozilla/4.0(兼容; MSIE 5.01; Windows NT 5.0)";
webRequest.Timeout = 150000;
//创建POST数据并将其转换为字节数组.
webRequest.ContentLength = formData.Length;
WebResponse webResponse = null;
StreamReader objSR;
System.Text.Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
流objStream;
字符串sResponse;
webResponse =(HttpWebResponse)webRequest.GetResponse();
objStream = webResponse.GetResponseStream();
objSR = new StreamReader(objStream,encode,true);
//<< sResponse不包含Unicode字符值>>
sResponse = objSR.ReadToEnd();
Response.Write(sResponse);
</pre>

解决方案

减少超时以检查错误是什么...,根据错误描述做出决定.


hi
i have used the following method to send the file to validate the url but i am not getting any responce and my browser is in connecting stage and my code is as follows pl tell me how to solve it

my code is as follows

<pre lang="c#">
string url = "http://www.inspire-geoportal.eu/INSPIREValidatorService/resources/validation/inspire";
HttpWebRequest webRequest = WebRequest.Create(url) as HttpWebRequest;
webRequest.Headers.Clear();
webRequest.Headers.Add("Authorization", "text/html");
webRequest.Method = "POST";
webRequest.PreAuthenticate = true;
webRequest.ContentType = "application/xml";
webRequest.Credentials = CredentialCache.DefaultNetworkCredentials ;//.DefaultCredentials;
webRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
webRequest.Timeout = 150000;
// Create POST data and convert it to a byte array.
webRequest.ContentLength = formData.Length;
WebResponse webResponse = null;
StreamReader objSR;
System.Text.Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
Stream objStream;
string sResponse;
webResponse = (HttpWebResponse)webRequest.GetResponse();
objStream = webResponse.GetResponseStream();
objSR = new StreamReader(objStream, encode, true);
//<<sResponse doesn''t contain Unicode char values>>
sResponse = objSR.ReadToEnd();
Response.Write(sResponse);
</pre>

解决方案

reduce the timeout to check what is the error..., take the decision based on the error description.


这篇关于使用C#验证Inspiremetadata的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆