[teiid-issues] [JBoss JIRA] (TEIID-4366) Provide CORS support on OData Service

Ramesh Reddy (JIRA) issues at jboss.org
Fri Aug 5 10:04:00 EDT 2016


    [ https://issues.jboss.org/browse/TEIID-4366?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13275719#comment-13275719 ] 

Ramesh Reddy commented on TEIID-4366:
-------------------------------------

BTW, an example AngularJS client for VDB

loopy-vdb.xml (a simple mock vdb)
{code}
<vdb name="loopy" version="1">
    <model visible="true" name="PM1">
        <source name="loop" translator-name="loop"/> 
        <metadata type = "DDL"><![CDATA[        
            CREATE FOREIGN TABLE G1 (e1 integer PRIMARY KEY, e2 varchar(25), e3 double);
            CREATE FOREIGN TABLE G2 (e1 integer PRIMARY KEY, e2	 varchar(25), e3 double, e4 integer, FOREIGN KEY (e4) REFERENCES G1 (e1));
        ]]>
       </metadata>        
    </model>    
    <translator name="loop" type="loopback">
        <property name="IncrementRows" value="true"/>
        <property name="RowCount" value="10"/>
    </translator>    
</vdb>
{code}

AngularJS client

test.html
{code}
<html ng-app=ODataApp>
<head>
<title>Example to Consume web service from AngularJS App</title>
<script
	src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script type="text/javascript">
	var app = angular.module('ODataApp', []);
	app.controller('ODataController', function($scope, $http) {
		$http.defaults.headers.common.Authorization = 'Basic dXNlcjpyZWRoYXQxIQ==';
        $http.defaults.headers.common.Accept = 'application/json';

		$http({ method: 'GET', url: 'http://localhost:8080/odata4/loopy.1/PM1/G1'})
				.then(function mySucess(response) {
					$scope.data = response.data;
					// this callback will be called asynchronously
					// when the response is available
				}, function myerror(response) {
					alert(response.status);
					// called asynchronously if an error occurs
					// or server returns response with an error status.
				});
	});
</script>
</head>
<body>
	<div ng-controller="ODataController">

		<table>
			<tr>
				<th>e1</th>
				<th>e2</th>
			</tr>
			<tr ng-repeat="row in data.value">
				<td>{{ row.e1 }}</td>
				<td>{{ row.e2 }}</td>
			</tr>
		</table>
	</div>

</body>
</html>
{code}



> Provide CORS support on OData Service
> -------------------------------------
>
>                 Key: TEIID-4366
>                 URL: https://issues.jboss.org/browse/TEIID-4366
>             Project: Teiid
>          Issue Type: Enhancement
>          Components: OData
>    Affects Versions: 8.12
>            Reporter: Ramesh Reddy
>            Assignee: Ramesh Reddy
>              Labels: Alpha3
>             Fix For: 9.1
>
>
> Good write up CORS can be found here https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
> OData needs to implement CORS support to be valuable with java script based client development technologies.



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the teiid-issues mailing list