3

アダプターを Worklight サーバーにデプロイしましたが、ワークライト・アダプターを外部から残りのサーバーとして呼び出すという要件がいくつかあります。これは正常に機能し、必要に応じてデータを返しますが、json 出力を提供する代わりに、HTML を提供しています。

<!DOCTYPE html><html><head><meta charset="UTF-8" /><title>Invoke Procedure Result</title><script src="/secure/console/js/jquery-1.6.min.js"></script><style>   textarea {       width: 100%;   }   .textwrapper {       margin: 5px 0;       padding: 3px;   }</style></head><body onload="attachEvent();"><div><span id="invRes">Invocation Result of procedure: 'Authentication' from the Worklight Server</span>: </div><div id="target"><textarea rows="20">{
   "RESPONSE": {

      "USER_ID": "292265"
   },
   "errors": [
   ],
   "info": [
   ],
   "isSuccessful": true,
   "responseHeaders": {
      "Content-Length": "1195",
      "Content-Type": "text\/xml;charset=ISO-8859-1",
      "Date": "Thu, 21 Nov 2013 10:10:13 GMT",
      "Server": "Oracle GlassFish Server 3.1.2.2",
      "X-Powered-By": "Servlet\/3.0 JSP\/2.2 (Oracle GlassFish Server 3.1.2.2 Java\/Oracle Corporation\/1.7)"
   },
   "responseTime": 4234,
   "statusCode": 200,
   "statusReason": "OK",
   "totalTime": 4235,
   "warnings": [
   ]
}</textarea></div><script>function attachEvent() {$('#target').ajaxError(function(e, xhr, ajaxOptions, thrownError){$(this).text("Error: Please ensure that the XML input and XSL transformation are valid and try again.");});}function run_xslt() {var xml = $('#originalXML').val();var xsl = $('#originalXSL').val();$.post('/secure/dev/xslt',{'xml':xml,'xsl':xsl},function(data, textStatus, XMLHttpRequest){$('#target').empty();json = $("<textarea></textarea>");json.attr("rows",25);json.text(data);$('#target').append(json);$('#invRes').text('Result of Local XSL Transformation');},'text');}</script></body></html>

コードでは、HTML から再度解析し、json を文字列に格納しています。それなら私しか使えません。これは、ワークライトのドキュメントに従ってアダプターを外部から呼び出すための以下の URL です。

http://WorklightServer.com/secure/dev/invoke?adapter=Reports&procedure=Authentication¶meters=%5B%5D

4

2 に答える 2

4

URL から /dev/ コンポーネントを削除します。これは、開発を容易にするためだけのものです。それがなければ、JSON を取得できます。

于 2013-11-21T13:03:00.490 に答える