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
Consuming a webservice with headers
Re: Consuming a webservice with headers
Rachel, you should join your dad in the upcoming conference. It's a new up coming feature that will be showcased there.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
Re: Consuming a webservice with headers
In other words, it's not possible now?
Re: Consuming a webservice with headers
I can not answer that question with 100% conviction. But Vlad will be covering a session on this new feature for V8.1RLOMASKY wrote:In other words, it's not possible now?
Re: Consuming a webservice with headers
Are you trying to make two AwareIM programs "talk" to each other, Rachel?
Tom - V8.8 build 3137 - MySql / PostGres
Re: Consuming a webservice with headers
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.
But now it needs authentication, with a couple of simple JSON headers, so I need to be able to pass those as well.
Re: Consuming a webservice with headers
Sorry I can't help you with that, Rachel.
Tom - V8.8 build 3137 - MySql / PostGres
Re: Consuming a webservice with headers
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.
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
-
- Posts: 197
- Joined: Fri Jun 17, 2016 7:10 am
- Location: Brisbane Australia
- Contact:
Re: Consuming a webservice with headers
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
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
AWS Linux, Windows Server, AIM 8.4 & 8.6
Re: Consuming a webservice with headers
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
Bruce
Re: Consuming a webservice with headers
How did you accomplish it, Bruce?
Tom - V8.8 build 3137 - MySql / PostGres
-
- Posts: 7526
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: Consuming a webservice with headers
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.
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
Re: Consuming a webservice with headers
Rachel did NOT need any results sent back, so this works:tford wrote:How did you accomplish it, Bruce?
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 );
},
});`