为什么需要custom gateway官网

Integration Gateway: Using custom scripting to map data sources to entity sets - 推酷
Integration Gateway: Using custom scripting to map data sources to entity sets
In this blog I would like to introduce you to the custom scripting capabilities that were introduced with the Integration Gateway in SAP Mobile Platform 3.0 SP04. If you are interested in seeing which other new features were introduced, I can highly recommend you to read my colleagueMustafa'sblog:
A little while ago I wrote a blog/tutorial about
. As you could see in that blog, there was only a mapping capability available for SOAP data sources. For ODC, JDBC and JPA data sources this meant that the names of the entity sets and their properties had to correspond exactly to the fields of the data sources. Sometimes this resulted in rather ugly looking entity sets, as you had to keep the case lettering identical to the source and keep the technical field names of the source. You can see it in this example:
However, as of the latest release of SAP Mobile Platform, it is possible to create powerful enhancements using the JavaScript and Groovy scripting languages. After assigning a data source to an entity set, there some user exits are provided where you can modify the requests before they are sent to the data source, and modify the responses as they are returned from the data source. Some examples of what you can do with this are delta token handling, tombstone support, SOAP authentication, or data source mapping .
In the following, I'd like to show you how you can map an entity set to a JDBC data source using JavaScript. Taking the example from the image above, the result will look as follows, after having performed a data mapping:
Setting up the SAP Mobile Platform Tools
Along with the new service pack, a new set of OData modeling tools called SAP Mobile Platform Tools were released. You can find more information about this in my colleagueAmit'sblog:
The SAP Mobile Platform tools are based on Eclipse Kepler and support the new features of the SAP Mobile Platform 3.0 SP04. But of course they are downwards compatible and you may use them to work on your SP03 projects.
So, if you haven't done so already, please download Eclipse Kepler and install the SAP Mobile Platform Tools by following
Implementing the Data Mapping
1. Create a new project
Do a right click in the Project Explorer view and select: New & Other & SAP Mobile Platform & SAP Mobile Platform OData Implementation Project
Provide a project name and select the target runtime SAP Mobile Platform 3.0 SP4 .
Provide a model name, select Blank OData Model and finish the wizard.
2. Modeling the entity set and assigning the data source
Please model your entity set as follows:
Perform a right click on the JDBCmapping.odatasrv file and select Select Data Source . In the following wizard, assign the Data Source JDBC and finish.
3. Defining the Custom Code
Expand the nodes under the odatasrv-file, do a right click on Data Source JDBC and select Define Custom Code .
You may keep the suggested file name, and select the script type JavaScript .
Now Eclipse will open a JavaScript file with some sample coding. The script contains four JavaS processRequestData, processRequestSQL, processResponseData, processResponseResult:
4. Implementing the mapping
In order to do the mapping, we will need to implement the processRequestData function. Luckily, it comes with sample coding to perform such a mapping. The coding should look like this:
function processRequestData(message) {
//Import statements
importPackage(com.sap.gateway.ip.core.customdev.util);
importPackage(java.util);
importPackage(org.apache.olingo.odata2.api.edm);
importPackage(com.sap.gateway.mons);
importPackage(org.apache.olingo.odata2.api.uri);
importPackage (com.sap.gateway.ip.core.customdev.logging);
importPackage(com.sap.gateway.ip.core.customdev.api);
//Create the table map and populate with EntitySet name and DB Table name
var tableMap = new HashMap();
tableMap.put(&LocationsSet&,&COMPANYLOCATIONS&);
//Create the entity map and the two property maps
var entitiesMap = new HashMap();
var companyLocationsMap = new HashMap();
//Property map
companyLocationsMap.put(&LocationID&,&LOC_ID&);
companyLocationsMap.put(&LocationName&,&DESCRIPTION&);
//Entities map populated with property maps against relevant EntitySets
entitiesMap.put(&LocationsSet&, companyLocationsMap);
//Set the header in the message object with the two maps created
message.setHeader(ODataCamelExchangeHeaders.JDBC_TABLE_MAPPING.toString(), tableMap);
message.setHeader(ODataCamelExchangeHeaders.JDBC_PROP_MAPPING.toString(), entitiesMap);
//Logger this will log error to the console - useful for finding errors
log.logErrors(LogMessage.TechnicalError, message.getBody());
This is all you need to do to perform the mapping. Now you only need to deploy your project to the SAP Mobile Platform server, assign the JDBC destination to your entity set, and then you are done.
5. Testing the service
When you call your service, you will find that the mapping is in place, and it is returning the data from your database:
Thanks for reading, I hope you will find this helpful.
Kind regards
已发表评论数()
&&登&&&陆&&
已收藏到推刊!
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见GATEWAY_Chinese_version_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
评价文档:
128页免费13页免费213页免费54页免费98页5下载券15页免费20页免费36页免费74页5下载券8页免费
喜欢此文档的还喜欢19页免费24页免费30页免费10页免费22页5下载券
GATEWAY_Chinese_version|M​I​T​A10​远​程​监​控​系​统​操​作​说​明
把文档贴到Blog、BBS或个人站等:
普通尺寸(450*500pix)
较大尺寸(630*500pix)
你可能喜欢}

我要回帖

更多关于 gateway烧录卡 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信