반응형
[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");
}

+ Recent posts