我正在学习worklight(6.0)教程(Insurance App),在“Lab6_Integrate_With_Worklight_Apdaters_Part1_HTTPAdapter.pdf”一章中,我被告知如何创建一个过程并调用它。从worklight控制台URL获取json文件strait工作正常,但是当我根据教程构建过程时,我无法获取json文件(在“Invoke worklight过程”中),并收到错误:
[ERROR ] FWLSE0099E: An error occurred while invoking procedure [project InsuranceProj]CustomerDataAdapter/HttpRequestFWLSE0100E: parameters: [project InsuranceProj]{ "arr": [
{
"method": "get",
"path": "\/apps\/services\/www\/Insurance\/mobilewebapp\/default\/json\/Customer.json",
"returnedContentType": "json"
} ] } Failed to parse JSON string <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta content="en-us" name="DC.Language" />...... "
我正在做教程中的确切步骤,但无法找出错误的内容.... 我找不到任何解决这个问题的方法,希望能在这里得到一些答案
XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed Materials - Property of IBM
5725-G92 (C) Copyright IBM Corp. 2011, 2013. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or
disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-->
<wl:adapter name="CustomerDataAdapter"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.worklight.com/integration"
xmlns:http="http://www.worklight.com/integration/http">
<displayName>CustomerDataAdapter</displayName>
<description>CustomerDataAdapter</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>localhost</domain>
<port>10080</port>
<!-- Following properties used by adapter's key manager for choosing specific certificate from key store
<sslCertificateAlias></sslCertificateAlias>
<sslCertificatePassword></sslCertificatePassword>
-->
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="2" />
</connectivity>
<procedure name="getCustomerData">
<displayName>GetCustomerData</displayName>
</procedure>
</wl:adapter>
实施档案:
function getCustomerData() {
WL.Logger.debug("CustomerDataAdapter.getCustomerData procedure invoked");
var input = {
//headers : 'Content-Type: application/json',
method : 'get',
returnedContentType : 'json',
path : "/apps/services/www/Insurance/mobilewebapp/default/json/Customer.json"
};
return WL.Server.invokeHttp(input);
}
答案 0 :(得分:1)
当适配器过程向后端发出HTTP请求时,它需要返回一个JSON编码的数据字符串。从您显示的数据片段看,实际返回的内容似乎是HTML片段。我建议非常仔细地检查后端服务提供商返回的数据,以确定您是否获得了预期会看到的数据。
答案 1 :(得分:1)
您的适配器正在尝试从
获取JSONhttp://localhost:10080/apps/services/www/Insurance/mobilewebapp/default/json/Customer.json
这是一个回到你的项目的参考(一个相当奇怪的事情,但我想在实验室......)
在任何情况下,您的路径都缺少一个元素。它应该是:
path : "/Insurance/apps/services/www/Insurance/mobilewebapp/default/json/Customer.json"