Jerry used Nodejs to consume the standard webservice provided by C4C in the public article C4C and integrated series tutorials.
See a specific example: C4C individual customers can maintain social user profile, in the public article above Jerry, is to maintain the user's open ID to social users The Socialmediaaccountuserid field of the profile goes as shown.
So what is known as a social profile ID, how can I get that profile by using a Web service Nodejs?
First get the standard query social User profile's web Service to Administrator->input and Output Management->service Explorer:
Https://
Then use the Nodejs module request to send an HTTP POST request to this URL.
You can refer to the source code on my 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", head ERs: {"Content-type": "Text/xml", ' Authorization ': ' Basic ' + new Buffer (CONFIG.CREDENTIAL_QXL). ToS Tring (' base64 ')}, Body: ' <soapenv:envelope xmlns:soapenv= ' http://schemas.xmlsoap.org/soap/envelope/' xml ns:glob= "Http://sap.com/xi/SAPGlobal20/Global" ><soapenv:header/><soapenv:body><glob: Socialmediauserprofilerequest_sync> ' + ' <SocialMediaUserProfileSelectionByElements> ' + ' <SelectionBySocialMediaUserProfileID> ' + ' <inclusiOnexclusioncode>i</inclusionexclusioncode> ' + ' <intervalboundarytypecode>1</interval Boundarytypecode> ' + ' <lowerboundarysocialmediauserprofileid > ' + profileID + ' </lowerboun Darysocialmediauserprofileid> ' + ' </SelectionBySocialMediaUserProfileID> ' + ' </SocialMediaUserProfileSelectionByElements> ' + ' </glob:socialmediauserprofilerequest_syn C></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 directly using node getsocialmediaprofiletest.js.
The body of the HTTP POST request sent and the response content returned from the console can be observed:
To get more original Jerry's technical articles, please follow the public number "Wang Zixi" or scan the QR code below:
Use Nodejs to consume the Web service on SAP Cloud for customer