Consuming a webservice with headers

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
RLOMASKY
Posts: 60
Joined: Mon Jan 16, 2017 10:10 pm

Consuming a webservice with headers

Post by RLOMASKY »

I'd like to consume a webservice from Aware. I don't need to process the output, just call it. I have a couple of headers to send along. I've found a lot on this forum about how to publish a webservice, not not how to consume it. Please point me in the right direction. I've seen mentions of plug-ins. Any examples of those?

Thanks,
Rachel
BenHayat
Posts: 2749
Joined: Thu Dec 23, 2010 5:48 am
Location: Fla, USA
Contact:

Re: Consuming a webservice with headers

Post by BenHayat »

RLOMASKY wrote:I'd like to consume a webservice from Aware. I don't need to process the output, just call it. I have a couple of headers to send along. I've found a lot on this forum about how to publish a webservice, not not how to consume it. Please point me in the right direction. I've seen mentions of plug-ins. Any examples of those?

Thanks,
Rachel
Rachel, you should join your dad in the upcoming conference. It's a new up coming feature that will be showcased there.
RLOMASKY
Posts: 60
Joined: Mon Jan 16, 2017 10:10 pm

Re: Consuming a webservice with headers

Post by RLOMASKY »

In other words, it's not possible now?
BenHayat
Posts: 2749
Joined: Thu Dec 23, 2010 5:48 am
Location: Fla, USA
Contact:

Re: Consuming a webservice with headers

Post by BenHayat »

RLOMASKY wrote:In other words, it's not possible now?
I can not answer that question with 100% conviction. But Vlad will be covering a session on this new feature for V8.1
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Consuming a webservice with headers

Post by tford »

Are you trying to make two AwareIM programs "talk" to each other, Rachel?
Tom - V8.8 build 3137 - MySql / PostGres
RLOMASKY
Posts: 60
Joined: Mon Jan 16, 2017 10:10 pm

Re: Consuming a webservice with headers

Post by RLOMASKY »

No, I'm trying to make an Aware program trigger something in an external (nothing to do with Aware) API. I used to do with a DISPLAY URL: DISPLAY URL 'https://api.mycompany.com/import/' + AS_STRING(BO.EXT_id, '####')

But now it needs authentication, with a couple of simple JSON headers, so I need to be able to pass those as well.
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Consuming a webservice with headers

Post by tford »

Sorry I can't help you with that, Rachel.
Tom - V8.8 build 3137 - MySql / PostGres
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: Consuming a webservice with headers

Post by BobK »

Rachel,

If you have access to a server with php loaded on it:
Create a php program to call the web service
Inside Aware use DISPLAY URL to call your php program.
Bob
UnionSystems
Posts: 197
Joined: Fri Jun 17, 2016 7:10 am
Location: Brisbane Australia
Contact:

Re: Consuming a webservice with headers

Post by UnionSystems »

Hi Rachel,

My understanding is that until v8.1 arrives the best way to do this is through development of a Java plugin. I don’t know how to write Java so as an interim I’ve developed a technique to consume REST services that uses Python scripts. I gave an example at https://www.awareim.com/forum/viewtopic ... hon#p43966.
T
There are heaps of examples on the web of Python scripts interacting with web services with minimal code. Anyway my basic scheme is :

1. Outside of AwareIM develop a hard coded Python script that achieves your requirment and reports its results in the form of a AwareIM import friendly CSV file.
2. Convert that script into an AwareIM document template that uses <<Object.Attribute>> tokens to inject variable data into the script
3. Write a process that does the following :
- Exports the Python document template onto your server
- Executes that Python script
- Imports the CSV file output by the Python

The beauty of Python is it has lots of simple ways to deal with things like parsing JSON and XML, constructing headers for REST requests, construct text files etc. And it’s relatively easy to code. I’ve used it to Geocode addresses and interact with web services that send SMS messages.

Looking forward to the conference in Providence :D
AWS Linux, Windows Server, AIM 8.4 & 8.6
BLOMASKY
Posts: 1476
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: Consuming a webservice with headers

Post by BLOMASKY »

Actually, I showed Rachel how to do it. Its is fairly simple AS LONG as you do not need custom headers. (I was able to handle cross-domain issues on the server).

Bruce
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Consuming a webservice with headers

Post by tford »

How did you accomplish it, Bruce?
Tom - V8.8 build 3137 - MySql / PostGres
aware_support
Posts: 7526
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: Consuming a webservice with headers

Post by aware_support »

Is this discussion about consuming a SOAP web service or REST web service?

Consuming a REST service is only fully supported in the upcoming 8.1 version (where you will be able to explicitly specify the headers of the request).

In 8.0 you need a Java plugin for this.
Aware IM Support Team
BLOMASKY
Posts: 1476
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: Consuming a webservice with headers

Post by BLOMASKY »

tford wrote:How did you accomplish it, Bruce?
Rachel did NOT need any results sent back, so this works:
EXEC_SCRIPT `$.ajax({
type: 'POST',
url: 'http://localhost:3301/printOrderAck',
contentType: 'application/json',
data: JSON.stringify({
option : 'email',
orderNo : ` + LoggedInRegularUser.lastOrderNumber + `,
outputFile : 'orderAck.pdf',
email : '[email protected]'
}),
dataType: 'text',
success: function( response ){
console.log( response);
},
error: function( error ){
// Log any error.
console.error( 'ERROR:', error );
},
});`
Post Reply