Brendan Tompkins

Sponsors

The Lounge

Wicked Cool Jobs

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Homeland Security Threat Level Service Anyone?

I've been tasked with creating a control to display the current Homeland Security Threat Level on our site's home page.  Of course, I don't want to change anything when our threat level changes, so I went in search of a Web Service that gives me this information.  I couldn't find a SOAP service, but I did find this URL provided by the Department of Homleand Security, which gives an XML string containing the current threat level.

I created this following enumeration that represents the current condition, so that I can use this information from within our .NET framework.

public enum DHSAdvisoryLevel
{
    SEVERE,
    HIGH,
    ELEVATED,
    GUARDED,
    LOW,
    UNKNOWN
}

And this static method to parse the DHSA's XML and return my enum.

public static DHSAdvisoryLevel GetHomelandSecurityThreatLevel()
{
      DHSAdvisoryLevel currentLevel = DHSAdvisoryLevel.UNKNOWN;
      try
      {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load("http://www.dhs.gov/dhspublic/getAdvisoryCondition");
            System.Xml.XmlNodeList el = doc.GetElementsByTagName("THREAT_ADVISORY");
            string threatLevel = el[0].Attributes["CONDITION"].Value;
            currentLevel = (DHSAdvisoryLevel) Enum.Parse(typeof(DHSAdvisoryLevel), 
            threatLevel, true);
      }
      catch 
      { 
            // Do something here, if needed 
      }
      return currentLevel;
}

Now, what would be really cool is for someone to host a Web Service that returns this enum... Any takers?

-Brendan


Posted Fri, Jan 30 2004 1:21 PM by Brendan Tompkins

[Advertisement]

Comments

b0b wrote re: Homeland Security Threat Level Service Anyone?
on Fri, Jan 30 2004 9:18 AM
Why bother. If the DHS already has this url available, who's going to be more reliable for this information? A web service that relies on this? Or just relying on this directly?
Brendan Tompkins wrote re: Homeland Security Threat Level Service Anyone?
on Fri, Jan 30 2004 1:33 PM
I'd think that a web service should be more reliable than a bunch of people parsing xml and using this xml string un-typed. It's also much easier to consume a web service, than to parse xml, and hope the XML structure stays the same... If they ever change their implemenation, that one person would do the update... Really, the DHS should host the service. I dunno.. It was just a thought.
Brian Desmond wrote re: Homeland Security Threat Level Service Anyone?
on Fri, Jan 30 2004 4:52 PM
I'll host it. Send me a zip file with the code, binaries.
sdk wrote re: Homeland Security Threat Level Service Anyone?
on Sat, Jan 31 2004 3:45 PM
believe a service like this exists on
xmethods.com
Brendan Tompkins wrote re: Homeland Security Threat Level Service Anyone?
on Mon, Feb 2 2004 1:23 AM
sdk,

Thanks, I did find the threatLevel service at xmethods. I couln't succesfully add a web refrence to this service however... I kept getting the following error:

Custom tool error: Unable to import WebService/Schema. Unable to import binding 'threat.cfcSoapBinding' from namespace 'http://DefaultNamespace'. Unable to import operation 'threatLevel'. Types must be declared at the top level in the schema.

The service is in ColdFusion, I wonder if it's coded improperly?

-Brendan
Brendan Tompkins wrote re: Homeland Security Threat Level Service Anyone?
on Tue, Feb 3 2004 2:02 AM
Brian,

Thanks for the offer to host this. I ended up hosting it here at VIT.

http://www.vit.org/WebServices/HomelandSecurityService.asmx

I couldn't get the ColdFusion service to work properly. I also wanted to return the Coast Guard's MARSEC level as well.

-Brendan

grant wrote re: Homeland Security Threat Level Service Anyone?
on Mon, Feb 9 2004 2:30 PM
Brendan, if you still need a host for this (or any other cool service you create) let me know and we can get WeProgram.Net or another OptimizeIT server to do it.
Brendan wrote re: Homeland Security Threat Level Service Anyone?
on Tue, Feb 10 2004 1:17 AM
Thanks Grant! Maybe I'll take you up on it. I ended up hosting the homeland security service here, since I returned MARSEC levels too, which relates to our core business.

Thanks again!
Darrell wrote re: Homeland Security Threat Level Service Anyone?
on Sat, Mar 6 2004 7:09 AM
Hey Brendan,

I was playing around with this and found out that you can get the DHS images to go along with the level. You could return that as part of your web service, and people could set that up if they wanted an image.
Brendan Tompkins wrote re: Homeland Security Threat Level Service Anyone?
on Sat, Mar 6 2004 10:15 AM
Hey Darrell...

Yeah. You can. Do you know if these are hosted somewhere? I don't want to get in the business of hosting a bunch of GIFs..

B
Paul Watson wrote re: Homeland Security Threat Level Service Anyone?
on Thu, Apr 29 2004 8:19 AM
Nice one, you just provided the answer for a CPian (http://www.codeproject.com/lounge.asp?msg=806754#xx806754xx).
Brendan Tompkins wrote re: Homeland Security Threat Level Service Anyone?
on Thu, Apr 29 2004 8:44 AM
Nice.. Glad to help!
DEV wrote re: Homeland Security Threat Level Service Anyone?
on Tue, Feb 1 2005 6:31 AM
thanks Brendan for the URL
free bingo online games wrote re: Homeland Security Threat Level Service Anyone?
on Tue, May 26 2009 4:00 AM

you can get the DHS images to go along with the level. You could return that as part of your web service, and people could set that up if they wanted an image. Thanks, I did find the threat Level service at x methods. I couldn't successfully add a web reference to this service however... I kept getting the following error...

www.onlinebingo4free.com

Tfnlumja wrote re: Homeland Security Threat Level Service Anyone?
on Tue, Jul 14 2009 6:04 AM

fglWxi

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Devlicio.us