Call an HTTP Service - anyone using it?

Imports, export, webservices, custom integration work, 3rd party software plugins etc. Questions about these topics live here.
steve
Posts: 399
Joined: Wed Nov 30, 2011 10:20 pm
Been thanked: 85 times

Call an HTTP Service - anyone using it?

Post by steve » Thu Dec 01, 2011 9:04 pm

I'd be interested to hear from anyone using the "Call an HTTP Service" feature.
We have it -almost- working with Google Maps API to provide driving distances and journey times. Proclaim will query the API, return the correctly formatted XML response, but Proclaim can't handle the response.
Eclipse are looking into this at the moment, but has anyone else used this feature successfully for anything else?

Ste Kearns
Posts: 2
Joined: Tue Mar 13, 2012 9:47 am

Re: Call an HTTP Service - anyone using it?

Post by Ste Kearns » Tue Mar 13, 2012 10:56 am

I haven't used web services calls from Proclaim for calling 3rd party web services but I have coded my own locally hosted web services.

First I tried to do this in PHP but had no success. Proclaim seemed unable to parse the generated WSDL documents that came out of the libraries I was using.

All the web services I use now are written as legacy ASMX services and they work just fine. For instance, I have a service called WorkingDays which accepts two dates and returns the number of working days between the two. This is called from various maths items that appear on a number of different reports and screens.

Pity Proclaim doesn't support WCF services though

steve
Posts: 399
Joined: Wed Nov 30, 2011 10:20 pm
Been thanked: 85 times

Re: Call an HTTP Service - anyone using it?

Post by steve » Tue Mar 13, 2012 11:19 pm

Interesting approach - Thanks Ste
Do you add the maths field that calls the webservice directly to the report, or is it calculated then stored in a text field to be added to the report?
I'd be interested to know how fast it performs the webservice call to a local server for you and whether it impacts on large query results significantly (reports/onscreen SQLs etc).
Cheers
Steve

Ste Kearns
Posts: 2
Joined: Tue Mar 13, 2012 9:47 am

Re: Call an HTTP Service - anyone using it?

Post by Ste Kearns » Thu Mar 15, 2012 11:51 am

Your reply tells me you can guess the downside!
Although the web service runs like lightning on our network (served from IIS on Windows Server 2008), calling it from a Maths field that is added directly to a report has some overhead.
If you need just one web service call per report row returned it's bearable but adding multiple fields for different purposes in a single report gets painfully slow.

For data on screens it isn't a problem, all runs pretty quick.

When I get a sec, I'll measure times for 1 and multiple fields in reports and share the results

steve
Posts: 399
Joined: Wed Nov 30, 2011 10:20 pm
Been thanked: 85 times

Re: Call an HTTP Service - anyone using it?

Post by steve » Thu Mar 15, 2012 5:56 pm

Thanks Ste, although I think it rules it out of large jobs for us.
I think careful design of the maths calling the webservice should reduce run-time for reports on second and subsequent runs at least,
for example, if you set a flag {working days refresh needed} = YES if the source dates change, then your maths to display the working days could be something like... (pseudocode)

Code: Select all

IF {working days refresh needed.Code}= "yes" then
   #need to recalculate workingdays - result is stored into {working days.Value} non maths field
   WEBSERVICE("workingdays",ipStart,ipEnd,opDAYSfield")
ELSE
   #nothing changed - don't recalculate   
END
#return the result from the static value field, regardless of whether it has been refreshed or otherwise
result = {working days.Value}

There are numerous ways you can flag whether the values have changed - intelligence on fields on screens, or my personal favourite which is to create holding fields for 'last processed' values, then at an opportune moment you can compare the current value to the last processed values.

Code: Select all

IF {start date.Date} <> {start date last processed.Date} OR {end date.Date} <> {end date last processed.Date} then
   #need to recalculate workingdays - result is stored into {working days.Value} non maths field
   WEBSERVICE("workingdays",ipStart,ipEnd,opDAYSfield")
#store the current dates in the 'last processed' dates for change detection next time
put ({start date.Date}, {start date last processed.Date})
put ({end date.Date}, {end date last processed.Date})
update ({case.key},"")
ELSE
   #nothing changed - don't recalculate   
END
#return the result from the static value field, regardless of whether it has been refreshed or otherwise
result = {working days.Value}
this would work for on-screen SQL with updates allowed=YES, but may not work on a report as by default they are NO-UPDATE allowed from called maths fields. You can of course add the change detection fields to the linked action run at Case Save.

steve
Posts: 399
Joined: Wed Nov 30, 2011 10:20 pm
Been thanked: 85 times

Re: Call an HTTP Service - anyone using it?

Post by steve » Thu Mar 15, 2012 6:16 pm

We have it working now for a call to the Google Distance API, which calculates the distance between two postcodes.

(this is using "HTTP service administration" and "Call an HTTP service" maths item, as opposed to "Web Service Adminstration" and "Call a Web Service")

it required a fix from Eclipse to get it working on 3.2.9, and a caveat that you couldn't pass it a {correspondent.Postcode} entry, but rather it had to be a text field, i.e. a maths field text output e.g. {M client postcode as alpha.Text}
result = {client.Postcode}

Make sure to follow the API T&C - namely you must show a google map that corresponds to the Distance calculation along with the results. You can do this with a web browser embedded on a screen, whose URL you can construct using maths (search for Google Static Map API).

I'll post the settings under "HTTP service maintence" some day soon for reference - this is going to be a great little tool now it works!

StephenM
Posts: 49
Joined: Tue Dec 13, 2011 10:44 am
Has thanked: 4 times
Been thanked: 2 times

Re: Call an HTTP Service - anyone using it?

Post by StephenM » Wed May 02, 2012 8:40 am

Would be fascinated to see the result of this as well as the code, as we are currently attempting to do something similar.

Thanks

steve
Posts: 399
Joined: Wed Nov 30, 2011 10:20 pm
Been thanked: 85 times

Re: Call an HTTP Service - anyone using it?

Post by steve » Wed May 02, 2012 9:31 am

  • create 2 maths fields to pass the source and destination postcodes at text fields to the HTTP service (fields must be passed as .Text, not .Postcode)
    eg result = {Client.Postcode}
  • create 2 alpha fields to accept the result of the HTTPservice
    e.g. {google duration.Text} and {google distance.Text}
  • set up an XML data template for the GoogleDistanceMatrix
    - import the following XML

    Code: Select all

    <?xml version="1.0" encoding="UTF-8"?>
    <DistanceMatrixResponse>
    <status>OK</status>
    <origin_address>Stockport SK1 1AA, UK</origin_address>
    <destination_address>Manchester M1 1AA, UK</destination_address>
    <row>
    <element>
    <status>OK</status>
    <duration>
    <value>Google Duration.Text</value>
    <text>19 mins</text>
    </duration>
    <distance>
    <value>Google Distance.Text</value>
    <text>9.0 km</text>
    </distance>
    </element>
    </row>
    </DistanceMatrixResponse>
    Image
  • then in the fields list, tag the value lines of Google Distance and Google Duration with your text fields as above to store the result.
    Image
  • create an ImportExport job to use the above template - choose type=XML, select your XML template, set the SQL field = case.key in the field chooser
    Image
  • set up the HTTP service job as per below screenshot
    Image
    (WEB address is:
    http://maps.googleapis.com/maps/api/distancematrix/xml
    SEND options can be blank
  • Create a linked action to attach to a button/process, use the wizard to Call an HTTP service. The code will be something like

    Code: Select all

    HTTPSERVICE( "002" ) 
    MESSAGE( return-value ) 
    nb you can use the MESSAGE (return-value) to debug the HTTP service response - it will give the result of the underlying HTTPservice procedure call which can be helpful. you don't need it.
  • set up a screen to test if you like with your source and result fields on. Tag a button with a linked action and off you go. The data fields chosen above are returned are in metres (distance) and seconds (duration)
  • you can use Wireshark for debugging as the requests are sent in plain text with the above settings. I think Proclaim is supposed to log the HTTP traffic to c:\temp, but this stopped working for me.
You should be able to switch to HTTPS but I haven't tested this yet - I suspect you will need to install the google certificate on each client machine as per the RTA portal certificate.

please be aware of the licensing restrictions of the google API:
"Use of the Distance Matrix API must relate to the display of information on a Google Map; for example, to determine origin-destination pairs that fall within a specific driving time from one another, before requesting and displaying those destinations on a map. Use of the service in an application that doesn't display a Google map is prohibited"

I leave it to you to satisfy these requirements in addition to the above code.

https://developers.google.com/maps/docu ... ncematrix/

StephenM
Posts: 49
Joined: Tue Dec 13, 2011 10:44 am
Has thanked: 4 times
Been thanked: 2 times

Re: Call an HTTP Service - anyone using it?

Post by StephenM » Fri May 11, 2012 8:48 am

Only thing missing here appears to be the import export template. You've got it showing in the receive bit of the http Service but no detail on the settings.

steve
Posts: 399
Joined: Wed Nov 30, 2011 10:20 pm
Been thanked: 85 times

Re: Call an HTTP Service - anyone using it?

Post by steve » Fri May 11, 2012 9:20 am

oop,
amended the original post to include the importexport template

Post Reply