2016-09-01 4 views
3

SOAP Webサービスからデータを取得するためにJavaScript HTTPアダプタを使用しようとしています。そのために、私はType8でMFP8とIonicを使用しています。MobileFirst 8のJS HTTPアダプタでメソッドを追加

私は、次のアダプタ実装ファイルを持っている

function getFeed(params) { 
    var sr = 
      "<soapenv:Envelope " + 
      "xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" " + 
      "xmlns:len=\"targetNamespace HERE" >" + 
      "<soapenv:Header/>"+ 
      "<soapenv:Body>" + 
      "<len:authentication>" + 
      "<username>"+params[0]+"</username>"+ 
      "<password>"+params[1]+"</password>"+ 
      "</authentication></soapenv:Body></soapenv:Envelope>"; 

    var input = { 
     method : 'post', 
     returnedContentType : 'xml', 
     path : 'PATH HERE', 
     body: { 
      content: sr, 
      contentType: 'text/xml; charset=utf-8', 
      }, 
    }; 
    return MFP.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> 

は、APIドキュメントを、次の、私は内のアダプタを呼び出すために次のことをやりました私のイオンプロバイダー

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)); 
     } 
    ); 

SOAPサービスから特定のデータを取得する必要があるためe。そのためには、メソッドと同様にパラメータを渡す必要があります。

ナレッジセンターでは、クエリーストリングでパレメーターを呼び出す方法を見つけました。パラメータを渡すことができます。

私の要件は、メソッド名も渡すことです。

誰でもメソッド名を渡す方法を教えてもらえますか?

誰もが助けてくれます!

答えて

2

あなたが望むようにあなたがたとえば、あなたがこのような何か行うことができますが、できるだけ多くのパラメータを渡すことができます。アダプターで

function getFeed(method, username, password) { 
    var sr = 
      "<soapenv:Envelope " + 
      "xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" " + 
      "xmlns:len=\"targetNamespace HERE" >" + 
      "<soapenv:Header/>"+ 
      "<soapenv:Body>" + 
      "<len:authentication>" + 
      "<method>"+method+"</method>"+ 
      "<username>"+username+"</username>"+ 
      "<password>"+password+"</password>"+ 
      "</authentication></soapenv:Body></soapenv:Envelope>"; 

    var input = { 
     method : 'post', 
     returnedContentType : 'xml', 
     path : 'PATH HERE', 
     body: { 
      content: sr, 
      contentType: 'text/xml; charset=utf-8', 
      }, 
    }; 
    return MFP.Server.invokeHttp(input); 
} 

とクライアントで:

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

要求のJSON配列の構文は、パラメータがネットワーク経由で渡される方法に過ぎません。アダプタで配列を返すことを意味するものではありません。配列の最初の要素を最初の関数パラメータに、2番目の要素を2番目のパラメータに割り当てるなどして動作します。

+0

私はそれを試しました。私は方法を得ることができません –

+1

ええ!それは今働いている。ありがとうございました。 –

関連する問題