DTN ProphetX® Web Services

HTTP

This section contains notes to help in accessing ProphetX Web Services using the HTTP protocol without SOAP.

ProphetX Web Services can be invoked via HTTP/GET using a regular HTTP query string like the following:

    OPERATION?PARAMETER1=VALUE2&PARAMETER2=VALUE2&...&PARAMETERn=VALUEn
A concrete example would be:
    https://pxweb.dtn.com/PXWebSvc/PXServiceWeb.svc/GetQuoteSnap?UserID=user&Password=pswd&Type=F&Symbol=MSFT,UIS,DTN,IBM

Most programming languages have the capability of sending HTTP requests. In particular, this is a relatively simple operation for scripting languages and this section includes some basic code fragments to show this technique.

It must be noted that PXWeb returns an XML string by default and it is up to the client side to decide on how to proceed to process the string. A common approach may be to convert the string into an XML object before any more processing. The client can also select different formats include HTML, CSV, or JSON with the Format parameter. See formats for more info.

Query strings sent to ProphetX Web Services must be encoded with UTF-8, and results from PXWeb are UTF-8 encoded as well.

Perl

    #!/usr/bin/perl -w
    use LWP::Simple;
    use URI::Escape;

    # URL and query string
    my $URL = 'https://pxweb.dtn.com/PXWebSvc/PXServiceWeb.svc';
    my $QUERY= 'GetQuoteSnap?UserID=user&Password=pswd&Type=F&Symbol=MSFT,UIS,@C`## 5,IBM';

    # Send request and print response as a string
    my $response = get uri_escape( "$URL/$QUERY", '#' );
    print $response;

Python

    #!/usr/bin/env python
    import urllib

    # URL and query string
    URL = 'https://pxweb.dtn.com/PXWebSvc/PXServiceWeb.svc'
    QUERY= 'GetQuoteSnap?UserID=user&Password=pswd&Type=F&Symbol=MSFT,UIS,@C`## 5,IBM'

    # Build and send the request
    request = '%s/%s' % ( URL, urllib.quote( QUERY, '?&=' ) )
    web = urllib.urlopen( request )

    # Get the response and print as a string
    response = web.read()
    print response

WGet

WGet is not a scripting language, but a common tool both in *nix and Windows platforms to access web sites.

    wget -O out.xml 'https://pxweb.dtn.com/PXWebSvc/PXServiceWeb.svc/GetQuoteSnap?UserID=user&Password=pswd&Type=F&Symbol=MSFT,UIS,@C`%23%23 5,IBM'