-1

我正在学习 worklight (6.0) 教程(保险应用程序),在“Lab6_Integrate_With_Worklight_Apdaters_Part1_HTTPAdapter.pdf”一章中,我被告知如何创建一个过程并调用它。从 worklight 控制台 URL 获取 json 文件海峡工作正常,但是当我根据教程构建过程时,我无法获取 json 文件(在“调用 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);

}
4

2 回答 2

1

您的适配器正在尝试从

http://localhost:10080/apps/services/www/Insurance/mobilewebapp/default/json/Customer.json

这是您项目的参考(这是一件相当奇怪的事情,但我想在实验室中......)

在任何情况下,您的路径都缺少一个元素。它应该是:

path : "/Insurance/apps/services/www/Insurance/mobilewebapp/default/json/Customer.json"
于 2013-11-11T14:35:14.717 回答
1

当适配器过程向后端发出 HTTP 请求时,它期望返回一个 JSON 编码的数据字符串。从您显示的数据片段来看,实际返回的似乎是一个 HTML 片段。我的建议是非常仔细地检查从后端服务提供商返回的数据,以确定您是否获得了您期望看到的数据。

于 2013-11-10T17:59:51.620 回答