日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

使用nodejs消费SAP Cloud for Customer上的Web service

發(fā)布時間:2023/12/19 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用nodejs消费SAP Cloud for Customer上的Web service 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Jerry在公眾號文章C4C和微信集成系列教程里曾經使用nodejs去消費C4C提供的標準webservice。

看一個具體例子:C4C里Individual Customers可以維護Social User Profile,在Jerry上面的公眾號文章里,正是把微信用戶的open ID維護到Social User Profile的SocialMediaAccountUserID字段去,如下圖所示。

那么已知一個Social Profile ID,如何用nodejs通過Web Service的方式獲得該Profile明細?

首先到Administrator->Input and Output Management->Service Explorer中取得標準的查詢Social User profile的web service:

https:///sap/bc/srt/scs/sap/requestforsocialmediauserprofi

然后使用nodejs module request給這個url發(fā)一個HTTP post請求。

您可以參考我github上的源代碼。

var request = require('request'); var config = require("../../config.js");function getSocialMediaProfile(profileID) {console.log("Jerry trace begin ***********************************");console.log("url: " + config.socialMediaProfileGetEndPoint);console.log("config.credential_qxl: " + config.credential_qxl);var ogetSocialMediaProfileOptions = {url: config.socialMediaProfileGetEndPoint,method: "POST",headers: {"content-type": "text/xml",'Authorization': 'Basic ' + new Buffer(config.credential_qxl).toString('base64')},body: '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:glob="http://sap.com/xi/SAPGlobal20/Global"><soapenv:Header/><soapenv:Body><glob:SocialMediaUserProfileRequest_sync>'+'<SocialMediaUserProfileSelectionByElements>'+'<SelectionBySocialMediaUserProfileID>'+'<InclusionExclusionCode>I</InclusionExclusionCode>'+'<IntervalBoundaryTypeCode>1</IntervalBoundaryTypeCode>'+'<LowerBoundarySocialMediaUserProfileID >' + profileID + '</LowerBoundarySocialMediaUserProfileID>'+'</SelectionBySocialMediaUserProfileID>'+'</SocialMediaUserProfileSelectionByElements>'+'</glob:SocialMediaUserProfileRequest_sync></soapenv:Body></soapenv:Envelope>'};console.log("body: " + ogetSocialMediaProfileOptions.body);console.log("Jerry trace end ***********************************");return new Promise(function(resolve,reject){request(ogetSocialMediaProfileOptions,function(error,response,body){console.log("Jerry web service response: " + body);var soapreg = /.*<SocialMediaUserAccountID>(.*)<\/SocialMediaUserAccountID>.*/;var soapresult = soapreg.exec(body);if( soapresult.length === 2){resolve(soapresult[1]);}});}); }module.exports = getSocialMediaProfile;

將上述代碼另存為文件getSocialMediaProfileTest.js, 直接使用node getSocialMediaProfileTest.js執(zhí)行。

從console能觀察到發(fā)送的HTTP post請求的body和返回的響應內容:

要獲取更多Jerry的原創(chuàng)技術文章,請關注公眾號"汪子熙"或者掃描下面二維碼:

總結

以上是生活随笔為你收集整理的使用nodejs消费SAP Cloud for Customer上的Web service的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。