-
1. Re: Teiid connect to REST DataSource with HTTP Header
rareddy Mar 16, 2018 7:01 PM (in response to rptmat57)How are you passing the Auth header? in the "invoke" function? Show me the code, you can trim to needed portions.
-
2. Re: Teiid connect to REST DataSource with HTTP Header
rptmat57 Mar 16, 2018 9:59 PM (in response to rareddy)Hi and thank you. I have been using Teiid designer and added the header parameter there, in the import webservice datasource wizard.
this is the auto generated xml from the model view:
affiliations_source.invokeHttp(action=>'GET',endpoint=>VARIABLES.qp,stream=>'TRUE',headers=>'{"\"Authorization\"":"Token token"}'))
where 'token' is the value I would normally pass.
-
3. Re: Teiid connect to REST DataSource with HTTP Header
rareddy Mar 16, 2018 11:11 PM (in response to rptmat57)So token is input parameter to the procedure?
Also how are you executing after you deployed in server?
-
4. Re: Teiid connect to REST DataSource with HTTP Header
rptmat57 Mar 16, 2018 11:23 PM (in response to rareddy)the token in a header parameter that should be sent to authenticate.
I am just using teiid jdbc connection and playing with the dashboard builder, after deploying a vdb with the above mentioned data source. and getting a 401 unauthorized.
if I try to execute a query connecting to the server vdb (using jdbc) from devstudio I get the same 401 error. but I don't have the error directly displaying data from the data source in devstudio
-
5. Re: Teiid connect to REST DataSource with HTTP Header
rareddy Mar 17, 2018 12:26 PM (in response to rptmat57)What i mean is are executing like
Exec myprocedure ('token')
And token this designed as a parameter to the procedure
-
6. Re: Teiid connect to REST DataSource with HTTP Header
rptmat57 Mar 17, 2018 12:40 PM (in response to rptmat57)oh no, I am not passing it as a parameter, I just used the word 'token' because I didn't want to copy paste the actual token.
again, it is not a parameter, just a value
-
7. Re: Teiid connect to REST DataSource with HTTP Header
rareddy Mar 17, 2018 2:51 PM (in response to rptmat57)in that case turn on DEBUG at the resource adapter layer in Teiid Server using the directions here and see what kind of request is being sent to the your service. See directions here in "All CXF Usage" section of Web Service Data Sources · Teiid Documentation
That fragment goes in your standalone-teiid.xml file in <wildfly>/standalone/configuration/standalone-teiid.xml file. Once you edit restart the server and then issue the command you should see the log that show the http request and response.
-
8. Re: Teiid connect to REST DataSource with HTTP Header
rptmat57 Mar 17, 2018 3:05 PM (in response to rareddy)yep, see it in the logs, but no authorization header passed:
ID: 1
Address: http://[URL}\]/api/v1/affiliations/
Http-Method: GET
Content-Type: text/xml; charset=utf-8
Headers: {User-Agent=[Teiid Server], Content-Type=[text/xml; charset=utf-8], Accept=[*/*]}
--------------------------------------
-
9. Re: Teiid connect to REST DataSource with HTTP Header
rareddy Mar 17, 2018 3:52 PM (in response to rptmat57)Then the VDB you deployed to the server does not have the "invoke" with token in it. Post the -vdb.xml file.
-
10. Re: Teiid connect to REST DataSource with HTTP Header
rptmat57 Mar 21, 2018 9:32 AM (in response to rareddy)I really don't understand why this is not working. I unzipped the vdb file, found the view and checked the xml and the header is there.
but in the server logs I can clearly see it's not being sent.
the vdb.xml file only contains contents referring to the other view files
-
11. Re: Teiid connect to REST DataSource with HTTP Header
rareddy Mar 21, 2018 11:23 AM (in response to rptmat57)How is the invoke definition XML/DDL looking like in your VDB? I suspect it is not using correctly. Post/attach your VDB here.
-
12. Re: Teiid connect to REST DataSource with HTTP Header
rptmat57 Mar 21, 2018 1:48 PM (in response to rareddy)here is my vdb.
now in the editor in the transformation I realized the header name "Authorization" had escaped quotes.
I tried removing them and was able to preview data from the view model, but still nothing from the local or deployed vdb
-
test_header.vdb.zip 39.7 KB
-
-
13. Re: Teiid connect to REST DataSource with HTTP Header
rareddy Mar 21, 2018 2:15 PM (in response to rptmat57)Can you provide the XML version of it pls?
-
14. Re: Teiid connect to REST DataSource with HTTP Header
rptmat57 Mar 21, 2018 2:31 PM (in response to rareddy)do you mean dynamic generated vdb?
if so, here it is:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<vdb name="test_header" version="1">
<description/>
<property name="validationDateTime" value="Wed Mar 21 13:31:03 EDT 2018"/>
<property name="validationVersion" value="8.12.5"/>
<model name="test_header_view" type="VIRTUAL">
<property name="imports" value="test_header_source"/>
<metadata type="DDL"><![CDATA[
SET NAMESPACE 'http://teiid.org/rest' AS REST;
CREATE VIRTUAL PROCEDURE test_header_view (
) RETURNS
TABLE (
creation_time string(4000),
country string(4000),
updated_time string(4000),
address string(4000),
notes string(4000),
formerly_known_as string(4000),
city string(4000),
type string(4000),
created_by string(4000),
zipcode string(4000),
organization string(4000),
updated_by string(4000),
id string(4000),
state string(4000),
department string(4000)
) OPTIONS(UPDATECOUNT '1')
AS
BEGIN
DECLARE STRING VARIABLES.qp = '';
SELECT
A.creation_time AS creation_time, A.country AS country, A.updated_time AS updated_time, A.address AS address, A.notes AS notes, A.formerly_known_as AS formerly_known_as, A.city AS city, A.type AS type, A.created_by AS created_by, A.zipcode AS zipcode, A.organization AS organization, A.updated_by AS updated_by, A.id AS id, A.state AS state, A.department AS department
FROM
(EXEC test_header_source.invokeHttp(action=>'GET',endpoint=>VARIABLES.qp,stream=>'TRUE',headers=>'{"\"Authorization\"":"Token ABcdedeadasda"}')) AS f, XMLTABLE('/response/response' PASSING JSONTOXML('response', f.result) COLUMNS creation_time string PATH 'creation_time/text()', country string PATH 'country/text()', updated_time string PATH 'updated_time/text()', address string PATH 'address/text()', notes string PATH 'notes/text()', formerly_known_as string PATH 'formerly_known_as/text()', city string PATH 'city/text()', type string PATH 'type/text()', created_by string PATH 'created_by/text()', zipcode string PATH 'zipcode/text()', organization string PATH 'organization/text()', updated_by string PATH 'updated_by/text()', id string PATH 'id/text()', state string PATH 'state/text()', department string PATH 'department/text()') AS A;
END;
]]></metadata>
</model>
<model name="test_header_source">
<source connection-jndi-name="test_header_source_DS" name="test_header_source" translator-name="ws"/>
</model>
</vdb>