| gif | history | intraday | java | news | objects | options | quote | soap | spots | tickers | weather | end of day | wddx |

Request:
 Spots
  Types:
   ·Query
   ·StandardXML
   ·Chart
Sample Code:
 Coldfusion
 ASP
 JSP
 PHP
 Perl
 
ASP
The ASP sample below uses a COM object called ASP tear. The code and other samples can be found at openwddx.org. In addition to the ASP Tear object there is a COM object that allows you to parse the WDDX XML packet returned from a query request. It is also included in the sample code below. FinWin owes it's thanks to Jason Alexander, from Transcoastal, for the excellent and concise example found below.

Active Server Page Example
<% 
Option Explicit 


Dim sHub, _ 
    iDays 
Dim sFinwinURL, _ 
    sPostData, _ 
        sContent 
Dim oRS, _ 
    oDeser, _ 
        oHttpObj 
Dim iRowNum, _ 
    iRecordCount 



Const REQUEST_POST      = 1 

' This is the user ID that was given to you by FinWin.  Development ID is 
' listed in the example
Const USER_ID           = 186 

' This is the user name for the account which you used to register on
' FinWin's site.
Const USER_NAME         = "myUsername"

' This is the password for the same account.
Const USER_PASSWD       = "myPassword"

' This is the URL that your page will post to in order to pull back the
' serialized WDDX packet.
Const FINWIN_URL        = "http://www.finwin.com/processCT/ProcessSpotTag.cfm" 



' Get the hub name that you want to query, either from a form post or get.
sHub                    = Request("hub") 

' Get the number of days that you wish to go back for the spot pricing. Again,
' you can get this from either a form post or get.
iDays                   = Request("days") 

' Create your two COM objects you'll be using.
Set oHttpObj            = Server.CreateObject("SOFTWING.AspTear") 
Set oDeser              = Server.CreateObject("WDDX.Deserializer.1") 

' Create your data string that you'll be posting to the previous page, FINWIN_URL.
sPostData               = "username=" & USER_NAME & "&password=" & USER_PASSWD & "&id=" 
                            & USER_ID & "&request=SPOTS&days=" & iDays & "&hub=" & sHub & "&type=query"

' Post to the page, retrieving any content.
sContent                = oHttpObj.Retrieve(FINWIN_URL, REQUEST_POST, sPostData, "", "") 

' The content should come back as a valid WDDX packet. Here, we deserialize it.
' NOTE: If the previous page returns an error, or failure code, the content string
'       will simply be the error string. You'll need to add in your own checking to make
'       sure that the returned content is a valid WDDX packet.
Set oRS = oDeser.deserialize(sContent) 


' Loop through all the records/rows returned from the serialization.
iRowNum = 1 
iRecordCount = oRS.GetRowCount 
For iRowNum = 1 To iRecordCount 

  ' Write out the values.
  ' NOTE: The field names are case sensitive. 
  Response.Write("HUB: " & oRS.GetField(iRowNum, "HUB") & "<br>") 
  Response.Write("HUBINDEX: " & oRS.GetField(iRowNum, "HUBINDEX") & "<br>") 
  Response.Write("SPOTPRICE: " & oRS.GetField(iRowNum, "SPOTPRICE") & "<BR>") 
  Response.Write("BASIS: " & oRS.GetField(iRowNum, "BASIS") & "<br>") 
  Response.Write("TRADINGDATE: " & oRS.GetField(iRowNum, "TRADINGDATE") & "<br>") 
  Response.Write("LOCATION: " & oRS.GetField(iRowNum, "LOCATION") & "<br>")

Next 


' Clean up behind yourself.
Set oHttpObj = Nothing 
Set oDeser   = Nothing 
Set oRS      = Nothing 

%>

DTN Market Access
9110 West Dodge Road, Suite 200   Omaha, Nebraska 68114
Copyright 2010, All rights reserved