반응형
[HttpGet]
public ActionResult GetCargoInfo(RtnFilesInfo value)
{
string str_crkyCn = value.crkyCn;
string str_cargMtNo = value.cargMtNo;
string str_mblNo = value.mblNo;
string str_hblNo = value.hblNo;
string str_blYy = value.blYy;
//화물관리번호 , BL 사용해서 했는지 확인 여부 필요.
try
{
string url = "https://unipass.customs.go.kr:38010/ext/rest/cargCsclPrgsInfoQry/retrieveCargCsclPrgsInfo?crkyCn=i220k129u161i054w030p040s2&cargMtNo=00ANLU083N59007001";
//uri = new Uri(url); // string 을 Uri 로 형변환
string responseText = string.Empty;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse())
{
HttpStatusCode status = resp.StatusCode;
Console.WriteLine(status); // 정상이면 "OK"
Stream respStream = resp.GetResponseStream();
using (StreamReader sr = new StreamReader(respStream))
{
responseText = sr.ReadToEnd();
Console.WriteLine(responseText);
}
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
string sURL;
sURL = "https://unipass.customs.go.kr:38010/ext/rest/cargCsclPrgsInfoQry/retrieveCargCsclPrgsInfo?crkyCn=i220k129u161i054w030p040s2&cargMtNo=00ANLU083N59007001";
WebRequest wrGETURL;
wrGETURL = WebRequest.Create(sURL);
WebProxy myProxy = new WebProxy("myproxy", 80);
myProxy.BypassProxyOnLocal = true;
wrGETURL.Proxy = WebProxy.GetDefaultProxy();
Stream objStream;
objStream = wrGETURL.GetResponse().GetResponseStream();
StreamReader objReader = new StreamReader(objStream);
string sLine = "";
int i = 0;
string ReadingText = "";
while (sLine != null)
{
i++;
sLine = objReader.ReadLine();
ReadingText += sLine;
//if (sLine != null)
// Console.WriteLine("{0}:{1}", i, sLine);
}
//MessageBox.Show(ReadingText);
//Console.WriteLine(ReadingText);
//Console.ReadLine();
System.Diagnostics.Debug.WriteLine(ReadingText);
return this.Content(ReadingText, "text/xml");
}
'IT > C#' 카테고리의 다른 글
[C#] DataSet을 xlsx 확장자 파일로 만들기 (0) | 2019.12.12 |
---|---|
[C#]RSS xml로 가져오기 (0) | 2019.12.05 |
[C#] URL로 XML을 받아 파싱하는 방법 (0) | 2019.11.07 |
[C#]난수 만들기 (영어 + 숫자) (0) | 2019.10.02 |
[C#]Visual Studio에서 결과 값 보이게 (0) | 2019.09.02 |