Jerry in the Public Document C4C and Wechat Integration Series Noejs was used to consume standard web services provided by C4C.
Take a concrete example: Individual Customers in C4C can maintain Social User Profile. In Jerry's public document above, it is the open ID of micro-credit users that is maintained in the Social Media Account User ID field of Social User Profile, as shown in the figure below.
So, given a Social Profile ID, how can we get the details of the Profile by using Noejs through Web Service?
First, go to Administrator - > Input and Output Management - > Service Explorer to get the standard web service that queries the Social User profile:
https://<host name>/sap/bc/srt/scs/sap/requestforsocialmediauserprofi
Then use nodejs module request to send an HTTP post request to the url.
You can refer to me. github On the source code.
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;
Save the above code as a file getSocialMediaProfileTest.js and execute it directly using node getSocialMediaProfileTest.js.
From console, the body of the HTTP post request sent and the content of the response returned can be observed:
For more articles on Jerry's original technology, please pay attention to the public number "Wang Zixi" or scan the following two-dimensional code: