It's hard to find code online that can do this, so after hours of poking around, I finally managed to get it done on my own. So, for the Web-i-verse, here is code that will download weather data through a proxy server as SOAP and then record that data in to a local Oracle XE database.
Yes, it wasn't easy figuring all this out.
You're welcome
$URL = New-Object System.Uri("http://www.webservicex.net/weatherforecast.asmx")
$Proxy = New-Object System.Net.WebProxy "192.168.1.80:8080"
#If you can't use default credentials, use the following two lines instead
#$Credentials = New-Object System.Net.NetworkCredential("User", "Password", "Domain");
#$Proxy.Credentials = $Credentials
$Proxy.UseDefaultCredentials = $true
#Zip Codes ...
#Kingman: 86401
#Lake Havasu City: 86403
#Nogales: 85621
#Tucson: 85701
$ZipList = @("86401", "86403", "85621", "85701")
for($J = 0 ; $J -lt $ZipList.Length ; $J++){
$SoapSender = New-Object System.Net.WebClient
$SoapSender.Proxy = $Proxy
$SoapSender.Headers.Add("Content-Type","text/xml;charset=UTF-8");
$SoapSender.Headers.Add("SOAPAction","""http://www.webservicex.net/GetWeatherByZipCode""")
[System.Net.ServicePointManager]::Expect100Continue = $false
#The above line stops HTTP 417 Expectation errors since SOAP servers don't usually send 100-Continue messages
$SoapMessage = @"
"@ + $ZipList[$J] + @"
"@
$Result = ([XML]$SoapSender.UploadString($URL, $SoapMessage))
$NsManager = New-Object System.Xml.XmlNamespaceManager($Result.NameTable)
$NsManager.AddNamespace("w", "http://www.webservicex.net")
$WeatherBase = $Result.SelectSingleNode("//w:GetWeatherByZipCodeResult", $NsManager)
$OracleHost = "127.0.0.1"
$OraclePort = "1522"
$OracleServiceName = "XE"
$OracleUser = "User"
$OraclePassword = "Password"
$OracleConnectionString = @"
Provider=msdaora;
Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=$OracleHost)(PORT=$OraclePort))(CONNECT_DATA=(SERVICE_NAME=$OracleServiceName)));
User Id=$OracleUser;
Password=$OraclePassword;
"@
$DbFactory = [System.Data.Common.DbProviderFactories]::GetFactory("System.Data.OleDb")
$DbConnection = $DbFactory.CreateConnection()
$DbConnection.ConnectionString = $OracleConnectionString
$DbCommand = $DbConnection.CreateCommand()
$DbCommand.CommandText = "Select 1 FROM DUAL"
$DbConnection.Open()
#$WeatherBase.SelectSingleNode("w:PlaceName", $NsManager).InnerText + ", " + $WeatherBase.SelectSingleNode("w:StateCode", $NsManager).InnerText
$CityName = $WeatherBase.SelectSingleNode("w:PlaceName", $NsManager).InnerText
foreach ($N in $WeatherBase.SelectNodes("w:Details/w:WeatherData", $NsManager)) {
$DateText = $N.SelectSingleNode("w:Day", $NsManager).InnerText
if($DateText -ne $null){
#get rid of the day off the front before we attempt to parse the string
$DT = [DateTime]::Parse($DateText.Substring($DateText.IndexOf(",") + 1))
$MaxTemp = $N.SelectSingleNode("w:MaxTem...
[More]