2
客戶端網站上有一個代理服務器,所有外部請求都必須經過。我正在調用需要代理設置的外部Web服務。在開發環境中設置虛擬代理服務器
我用來設置網絡請求代理的代碼可以在下面看到。
我會如何在我的開發人員環境中設置測試代理服務器來驗證我的代碼是否正常工作?
string url = String.Format("http://currencyconverter.kowabunga.net/converter.asmx/GetConversionAmount?CurrencyFrom={0}&CurrencyTo={1}&RateDate={2}&Amount={3}", CurrencyFrom.Text, CurrencyTo.Text, formattedDate, amount);
WebRequest request = WebRequest.Create(url);
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["proxyLogin"]))
{
WebProxy proxy = new WebProxy();
string proxyUrl = ConfigurationManager.AppSettings["proxyUrl"];
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["proxyPort"]))
{
proxyUrl += ":" +ConfigurationManager.AppSettings["proxyPort"];
}
// Associate the newUri object to 'myProxy' object so that new myProxy settings can be set.
proxy.Address = new Uri(proxyUrl);
// Create a NetworkCredential object and associate it with the
// Proxy property of request object.
proxy.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["proxyLogin"], ConfigurationManager.AppSettings["proxyPassword"]);
request.Proxy = proxy;
}
WebResponse response = request.GetResponse();
謝謝你有更多的信息嗎?我可以在Windows 2008開發環境中使用哪些代理軟件? – Burt
看到這個:http://www.youngzsoft.net/ccproxy/windows-server-proxy-server.htm和http://en.softonic.com/s/windows-proxy-server-2008更多。 – Neeta