簡體   English   中英

通過HTTP Adapter MFP 7.1調用REST WebServices

[英]Call REST WebServices via HTTP Adapter MFP 7.1

我們正在使用MFP7.1開發IONIC App。 我們正在嘗試使用HTTP適配器調用REST webservice來獲取一些數據。

我有以下適配器實現文件,

 function getFeed(username,password) {
  var data = {
    "username" : username,
    "password" : password
  };

    var input = {
        method : 'post',
        returnedContentType : 'plain',
        path : 'PATH HERE',
     body: {
        content: data.toString(),
        contentType: 'application/json; charset=utf-8;',
      },
    };
  return WL.Server.invokeHttp(input);
 }

這是adapter.xml,

<mfp:adapter name="http"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:mfp="http://www.ibm.com/mfp/integration"
             xmlns:http="http://www.ibm.com/mfp/integration/http">
  <displayName>http</displayName>
    <description>http</description>
    <connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>http</protocol>
      <domain>DOMAIN NAME HERE</domain>
      <port>PORT NO HERE</port>
            <connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
            <socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
            <maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>
        </connectionPolicy>
    </connectivity>
  <procedure name="getFeed"/>
</mfp:adapter>

我們做了以下操作來調用我的離子提供器中的適配器,

 var resourceRequest = new WLResourceRequest("adapters/http/getFeed", WLResourceRequest.GET);
   resourceRequest.setQueryParameter("params", "['username', 'password']");
   resourceRequest.send().then(
       function(response) {
            alert('response   '+JSON.stringify(response.responseText));
       },
       function(response) {
            alert("HTTP Failure  "+JSON.stringify(response));
       }
   );

我在錯誤日志中收到以下錯誤,

“errors \\”:[],\\“info \\”“statuscode \\”:400}“,”responseJSON“:{”statusReason“:”Bad Request“,”responseHeaders“:{”Transfer-Encoding“:”chunked“ ,“Server”:“Apache-Coyote / 1.1”,“Connection”:“close”,“Content-Type”:“text / plain”},“isSuccessful”:true,“不能在這里反序列化WEBSERVICE實體的實例。用戶在[Siyrce.org.apache.catal.inc.connector .......]的START_ARRAY令牌\\ n之外

根據評論中的建議,嘗試將.toString()更改為JSON.stringify

content:
    JSON.stringify(data)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM