Focal Point
[CLOSED]RESTful Web Services

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9997090386

July 13, 2016, 04:26 PM
Brian Garland
[CLOSED]RESTful Web Services
We just got licensed for this and I'm trying to figure out how to create a small Visual Basic program that can be run from the Windows command line to run a report by passing the path/filename of the .FEX. Has anyone done this? I found the example in the documentation but that doesn't really tell me how to create the actual .NET executable. I've got Visual Studio installed, but I'm no programmer.

This message has been edited. Last edited by: <Emily McAllister>,


WebFOCUS 8
Windows, All Outputs
July 14, 2016, 01:04 PM
dhagen
I suggest you baby step this one. Forget about WF Services, focus on building your VB knowledge first. You need to figure out how to consume a URL using VB, including HTTP request headers. Then you will have to figure out how to process the response - including the HTTP response headers.

Once you figured that out, then you can apply that knowledge to WF ReST Services.

This forum isn't the most appropriate for VB questions, but you can get lots of help with the WF Services that you would then need to consume.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
July 14, 2016, 01:46 PM
Squatch
File --> New --> Project

Visual Basic --> Windows --> Console Application

Module Module1

    Sub Main()
        For Each argument As String In My.Application.CommandLineArgs
            Process.Start(argument)
            Exit For
        Next
    End Sub

End Module

Build --> Build Solution

Your executable will be in one of two places, depending on whether you have selected "Debug" or "Release" mode:

C:\Visual Studio 20XX\Projects\ConsoleApplicationX\ConsoleApplicationX\bin\Debug\ConsoleApplicationX.exe

or

C:\Visual Studio 20XX\Projects\ConsoleApplicationX\ConsoleApplicationX\bin\Release\ConsoleApplicationX.exe

Then from a Windows command line in that directory:

ConsoleApplicationX.exe http://www.google.com



App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
July 14, 2016, 02:06 PM
Squatch
You will need to put the FEX under the Reporting Server area to avoid signing in to the WebFOCUS system.

Here is a real life hyperlink that runs a FEX I created. I pass two dates and a report title to the FEX:

http://webfocusdev/ibi_apps/WF...2016&WF_TITLE=Report

(Point your mouse at it to see the entire hyperlink, or click on it to see the hyperlink in your browser.)


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
July 14, 2016, 02:30 PM
Squatch
I forgot to mention that you will need to put double quotes around the hyperlink if you are passing parameters to the FEX:

ConsoleApplicationX.exe "http://webfocusdev/ibi_apps/WFServlet?IBIF_ex=cherwell/first_call_resolution/first_call_resolution_graph.fex&startDate=07142016&endDate=07142016&WF_TITLE=Report"

(The command line doesn't process the ampersands very well in this situation.)


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
July 14, 2016, 05:21 PM
Brian Garland
Thanks Squatch. That seems to be what I'm looking for. I'd like to see your actual VB code though. Mine seems to run the report just fine since I can see the agent start in the Reporting Console workspace, but I get an exception thrown on the very last line of code where the browser is supposed to open.

Here is my code:

Imports System.IO
Imports System.Net
Imports System.Text

Module Module1
Private cookies As CookieContainer
Private postData As String
Public WebBrowser As New Object
Public Property DocumentText As String

Sub Main()
Dim request2 As HttpWebRequest
Dim response2 As HttpWebResponse
Dim webStream2 As Stream
Dim webResponse2 As String = ""
request2 = WebRequest.Create("https://webfocus.simplot.com/ibi_apps/rs/ibfs/WFC/Repository/food_group/Customer_Service/Open_Orders.fex")
request2.UseDefaultCredentials = True
request2.PreAuthenticate = True
request2.Credentials = CredentialCache.DefaultCredentials
request2.Method = "POST"
'cookies is defined as CookieContainer in the Signing-On to WebFOCUS example
request2.CookieContainer = cookies
postData = "IBIRS_action=run"
Dim byteArray2 As Byte() = Encoding.UTF8.GetBytes(postData)
request2.ContentType = "application/x-www-form-urlencoded"
request2.ContentLength = byteArray2.Length
Dim dataStream2 As Stream = request2.GetRequestStream()
dataStream2.Write(byteArray2, 0, byteArray2.Length)
dataStream2.Close()
response2 = request2.GetResponse()
webStream2 = response2.GetResponseStream()
Dim webStreamReader2 As New StreamReader(webStream2)
While webStreamReader2.Peek >= 0
webResponse2 = webStreamReader2.ReadToEnd()
End While
WebBrowser.DocumentText = webResponse2
End Sub

End Module


WebFOCUS 8
Windows, All Outputs
July 14, 2016, 06:31 PM
Squatch
quote:
Originally posted by Brian Garland:
I'd like to see your actual VB code though.

There isn't any more code. What I posted is all there is. It isn't RESTful, but it meets the requirements you laid out:

1. It's code in Visual Basic created from Visual Studio.
2. It runs from the Windows command line.
3. It accepts a path/filename of a FEX to run a report.

I tested it today and it ran the FEX file I wrote about earlier. It opens a browser and displays a chart.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs