EmbeddedServer with Web Service as Data Source
websusk May 22, 2013 3:00 PMCurrently I am using the Teiid Embedded Server (8.2.0) to connect to 2 different databases. I have the 2 database connections working, and the virtual views are returning data. I now need to replace one of the database sources with a web service source. I'm having a hard time finding examples or a direction on how to do so outside of the Teiid Designer, which I am not using.
1) Are there special requirements that the given web service needs to follow?
- Does it have to be REST, or can any old web service that returns data be used? (Guessing WSDL URL is used as the endPoint)
2) The service in question required a call to a "login" method that returns an ID needed for any "get_data" call, so can multiple calls be used in 1 Teiid "get" call, such as "login() then get_data(), then logout()?
3) Any examples or can someone point me in the direction of the documentation for this? Can't seem to find it in the admin guide.
So, the following code is what I have for one of them (some changed, but the point is there)....
DataSource datasource = craeteDataSource(config); // create data source
EmbeddedServer.ConnectionFactoryProvider jdbcProvider = new EmbeddedServer.SimpleConnectionFactoryProvider(datasource);
teiidServer.addConnectionFactoryProvider("source-jdbc-db", jdbcProvider);
teiidServer.addTranslator(SQLServerExecutionFactory.class);
ModelMetaData metadata = new ModelMetaData();
Properties p = new Properties();
p.setProperty("importer.tableNamePattern", "TABLE_HERE");
metadata.setProperties(p);
metadata.setName("sql_db");
metadata.setSchemaSourceType("native");
metadata.addSourceMapping("sqlserver-connector-db", "sqlserver", "source-jdbc-db");
ModelMetaData metadataVirtualView = new ModelMetaData();
metadataVirtualView.setName("Data");
metadataVirtualView.setModelType(Type.VIRTUAL);
metadataVirtualView.setSchemaSourceType("ddl");
metadataVirtualView.setSchemaText(DATA_QUERY);
// deploy the VDB to the embedded server
teiidServer.deployVDB("Teiid", metadata,metadataVirtualView);