Accessing SOS with Basic Authentication - .Net (IronPython) 1

Posted by Linda Derezinski Mon, 23 Oct 2006 13:45:00 GMT

This example is provided by Kari Hoijarvi from WUSTL.

Download IronPython from http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython

Save the following code into a file called sos2.py

to run the code:

  ipy
  >>>import sos2
  >>>sos2.test()

The sos2.py file:

import clr;
import System
clr.AddReferenceByPartialName("System.Data")
clr.AddReferenceByPartialName("System.Web")
clr.AddReferenceByPartialName("System.Xml")
from System import *
from System.IO import *
from System.Net import *
from System.Net.Sockets import *
from System.Text import *
from System.Xml import *

def test():
    query = Encoding.UTF8.GetBytes(
"""<?xml version="1.0" encoding="UTF-8"?>
<GetObservation xmlns="http://www.opengeospatial.net/sos"
    xmlns:gml="http://www.opengis.net/gml"
    xmlns:ogc="http://www.opengis.net/ogc"
    xmlns:ows="http://www.opengeospatial.net/ows"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.opengeospatial.net/sos 
http://mars.uni-muenster.de/swerep/trunk/sos/0.0.31/sosGetObservation.xsd"
    service="SOS" version="0.0.31">
   <offering>EO1H0410342004085110PY</offering>
<observedProperty>urn:ogc:def:phenomenon:OGC:1.0.30:hyperion_B021</observedProperty>

<observedProperty>urn:ogc:def:phenomenon:OGC:1.0.30:hyperion_B051</observedProperty>
   <resultFormat>application/zip</resultFormat>
</GetObservation>
""")
    req = HttpWebRequest.Create("http://test.geobliki.com/sos")
    req.Method = "POST"
    req.Credentials = NetworkCredential("some", "user")
    req.ContentType = "text/xml; charset=\"UTF-8\"";
    req.ContentLength = query.Length
    req.UserAgent = "IronPython"
    reqstm = req.GetRequestStream()
    reqstm.Write(query, 0, query.Length);
    rsp = req.GetResponse();
    try:
        print "============ begin headers =================="
        for h in rsp.Headers:
            print h + ": " + rsp.Headers[h]
        print "============ end headers =================="
        print "============ begin response =================="
        print ""
        print StreamReader(rsp.GetResponseStream()).ReadToEnd()
        print ""
        print "============ end of response =================="
    finally:
        print "closing response"
        rsp.Close()

Accessing SOS with Basic Authentication - Ruby

Posted by Linda Derezinski Mon, 23 Oct 2006 13:26:00 GMT

Basic authentication in Ruby example.

This is using Ruby 1.8.4 which may be installed:

Windows: http://rubyforge.org/frs/?group_id=167

OSX: http://hivelogic.com/articles/2005/12/01/rubyrailslighttpdmysqltiger

Example XML to pass to the SOS is found http://eo1.geobliki.com/sosdemo

post_it(xml)


 def post_it( xml, user = "bob", pass = "test")
    url = URI.parse('http://eo1.geobliki.com/sos')
    req = Net::HTTP::Post.new(url.path)
    req.basic_auth(user, pass)
    req['Content-Type'] = "text/xml"
    req.body = xml
    @response = Net::HTTP.start(url.host, url.port){|http|
      http.request(req)
    }
    puts @response.body     

  end

Accessing SOS with Basic Authentication - Java

Posted by Linda Derezinski Mon, 23 Oct 2006 13:06:00 GMT

Basic authentication in Java example.

This uses JDK 5.0 and Apache jakarta commons libraries.

JDK download: http://java.sun.com/javase/downloads/index.jsp

Apache download: http://jakarta.apache.org/commons/index.html

Example XML to pass to the SOS is found http://eo1.geobliki.com/sosdemo

testPost(XML, "user", "password", false, "http://eo1.geobliki.com/sos");

If you are having issues with firewalls try changing the preempt to true to see if will work. This always sends the username/password with the request.

public static void testPost(String xml, String userName, String password, boolean preempt, String URL){
    HttpClient client = new HttpClient();
    HttpState state = client.getState();
    HttpClientParams params = client.getParams();
    params.setAuthenticationPreemptive(preempt);
    Credentials credentials = new UsernamePasswordCredentials(userName, password);
    state.setCredentials(null, null, credentials);
    PostMethod method = new PostMethod(URL);
    method.setRequestBody(xml);
    try {
        client.executeMethod(method);       
        Header[] headers = method.getResponseHeaders();
        for (Header header:headers){
            System.out.println(header.getName() + ":"+header.getValue());
        }
        String response = method.getResponseBodyAsString();
        System.out.println(response);
        method.releaseConnection();
    } catch (HttpException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }       
}

MapBuilder Vector Rendering

Posted by Patrice Cappelaere Mon, 16 Oct 2006 01:05:00 GMT

As part of OGS OWS-4 effort to deliver a GML client for the demo, Cameron is taking the code developed for the Geobliki WFS vector rendering and expanding it to support GML 3.2.

Vecor rendering is critical on the client side. SVG is used for Firefox 1.5 clients and VML for IE clients.

This will be critical for supporting Map Annotations to be stored in the new OWSContext document.

Check UML design here from Cameron’s blog

Responsive Space, Responsive Ground

Posted by Patrice Cappelaere Sat, 07 Oct 2006 23:20:00 GMT

Our lessons learned from the OFT/NRL development of VMOC is that Responsive Space will only take place when space data/assets can be made available to end users in a responsive manner.

The truth is that data exist. It is simply not available to end users in a timely for many reasons ranging from political to technical. Distributing data across organizations is an interoperability challenge. Tasking space assets across organizations is even more of a leap of faith.

These capabilities are desperately required for Maritime Awareness programs (Tactical Maritime Awareness, Maritime Domain Awareness, or Comprehensive Maritime Awareness…) or even closer to home for Emergency Response/Disaster Relief Efforts. Hurricane Katrina disaster proved, after the fact, that data could have been made available to NORTHCOM from many military or civil organizations.

Funded initially by OFT and NRL, GeoBliki rose from those emerging needs as a generic data node integrating all the standards defined by the Open Geospatial Consortium for Sensor Web Enablement. The first instantiation is at eo1.geobliki.com. With the support of NASA Goddard, this server will allow for the first time transparent access to space including data and tasking of a civilian satellite (EO-1) from any military or civil organizations prior to TACSAT-1 launch.

This capability can easily be cloned to thousands of space/ground/sea nodes generating data feeds for subscribers interested in satellite imagery, AIS ship tracks or pictures/videos taken by first responders. Aggregators like VMOC will be able to offer transparent tasking to civil or military assets in case of emergencies. Other assets such as UAV, field cameras could be tasked in a similar manner.

This coming December, the OGC will showcase an interoperability demo with more than 40 organizations/vendors. This will be the place to show responsiveness!

Older posts: 1 ... 16 17 18 19 20