Skip to Content
avatar image
Former Member

SMP access projects with constant connection id

Hi,

I want to get access to 3 different odata projects: prj1,prj2,prj3.

Each time I want to get access to only one of these odata projects.

Each project has constant connection id.

I need that in my app, when the user will choose a project, he will see the response of webservices of selected project.

How to write a function, that I will have access to selected project each time ?

This is my code of access to projects, but the code is working partially.

Regards, John

// define function initnew

factory.initnew = function (appisn)

{

var sUrl;

if (appisn===0)

{

// set url factory.asmxUrl="https://pmp.prj.com:8080/";

// set appid factory.appid="com.myprjis1.prjis1"; sUrl="https://pmp.prj.com:8080/odata/applications/latest/com.myprj.prj1/connections";

// set var factory.initFinished=false;

// init oHeaders factory.oHeaders={};

// set X-SMP-APPCID

factory.oHeaders['X-SMP-APPCID']="fd81ff8e-0851-4c06-5586-b2d0c0b997ab";

// get data in XML

factory.oHeaders['content-type']="application/xml"; }

else if (appisn===1)

{

// set url factory.asmxUrl="https://pmp.prj.com:8080/";

// set appid factory.appid="com.myprjis2.prjis2"; sUrl="https://pmp.prj.com:8080/odata/applications/latest/com.myprj.prj2/connections";

// set var factory.initFinished=false;

// init oHeaders factory.oHeaders={};

// set X-SMP-APPCID

factory.oHeaders['X-SMP-APPCID']="7b2a3e67-0e60-6766-18c1-dc6f3064434b";

// get data in XML

factory.oHeaders['content-type']="application/xml";

}

else if (appisn===2)

{

// set url

factory.asmxUrl="https://pmp.prj.com:8080/";

// set appid factory.appid="com.myprjis3.prjis3"; sUrl="https://pmp.prj.com:8080/odata/applications/latest/com.myprj.prj3/connections"; // set var factory.initFinished=false;

// init oHeaders factory.oHeaders={};

// set X-SMP-APPCID

factory.oHeaders['X-SMP-APPCID']="a500f420-1952-9534-7f62-8086e98c1a4b";

// get data in XML

factory.oHeaders['content-type']="application/xml";

}

// define struct of reading data from server oData.defaultHttpClient=sap.AuthProxy.generateODataHttpClient();

// define var factory.initFinished=true;

// message that init was finished

$rootScope.$broadcast('initFinished',true);

// define certification of server in app

factory.clientCert=new sap.AuthProxy.CertificateFromStore();

if (1)

{

// define request parameters

var request2 = {

headers: factory.oHeaders,

certificatesource:factory.clientcert,

requestUri:sUrl,

data : factory.connectionData,

method : "POST"

};

OData.request(request2,onSuccessForRegister2,onError);

}

else

{

alert("Have APPCID"); $rootScope.$applyAsync();

}

};

// if success registering

function onSuccessForRegister2(result) {

// set appCID

factory.appCID=result.ApplicationConnectionID;

localStorage.appcid=factory.appCID;

// set var clientCert

localStorage.clientCert=factory.clientCert;

// set rootScope with the new vars

$rootScope.$applyAsync();

}

// if not registering

function onError(error)

{

if ((error.response!=null)&&(error.response.statusCode!=null)&&(error.response.statusCode==200))

{

// init appCID = "" factory.appCID=""; localstorage.appcid="";

}

// end function

return;

}

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers