cancel
Showing results for 
Search instead for 
Did you mean: 

Using IConnectorGatewayService in NWDS CE 7.1

Former Member
0 Kudos

Hi everyone

I'm trying to use the IConnectorGatewayService within NWDS CE 7.1 to connect to an SAP backend (NetWeaver 2004), but can't seem to find the correct libraries to reference for this. Judging by the documentation, either the library names have changed or the means of referencing them has changed... or possibly both?

Has anyone else tried this? If so, how did you manage to get it to work?

I'm using this within an EJB.

Any help would be very much appreciated!

Thanks in advance

Stuart

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Ok... I've managed to get the correct libraries referenced, and everything is building ok.

However I can't run the app yet - there's an error when trying to get the IConnectorGatewayService.

Please could someone help with this? Do I need to set a reference in my application-j2ee-engine.xml file? Is there other config that's required for this to work?

Thanks

Stuart

Vlado
Advisor
Advisor
0 Kudos

Hi Stuart,

Yes, you specify runtime dependencies to external libraries, other apps, etc. in the application-j2ee-engine.xml. Setting the library reference in the IDE creates only the build time dependency.

Regards,

\-- Vladimir

Former Member
0 Kudos

Thanks Vladimir... that's very helpful.

Do you by any chance know what references I should set? I've added some config entries as I go along, although I'll admit I'm guessing entirely. I've included some code and config in case I'm doing something very obviously wrong.

This is an example of the code I'm using the get the connection to the backend:

private IConnection getConnection(String systemAlias)

throws Exception {

try {

Hashtable<String, String> env = new Hashtable<String, String>();

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sapportals.portal.prt.registry.PortalRegistryFactory");

InitialContext ctx = new InitialContext(env);

IUser user = UMFactory.getUserFactory().getUserByLogonID(sessionCtx.getCallerPrincipal().getName());

IConnectorGatewayService cgService = (IConnectorGatewayService)ctx.lookup(IConnectorGatewayService.KEY);

ConnectionProperties cProp = new ConnectionProperties(user.getLocale(), user);

if (cgService == null) {

throw new Exception("Connector Gateway Service not available");

}

return cgService.getConnection(systemAlias, cProp);

} catch (Exception ex) {

throw new Exception(ex);

}

}

...and this is what I have in my application-j2ee-engine.xml file:

<?xml version="1.0" encoding="UTF-8"?>

<application-j2ee-engine xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="application-j2ee-engine.xsd">

<reference reference-type="hard">

<reference-target provider-name="sap.com" target-type="library">

com.sap.security.api.sda

</reference-target>

</reference>

<reference reference-type="hard">

<reference-target provider-name="sap.com" target-type="library">

tc/epbc/connectivityfw/api

</reference-target>

</reference>

<reference reference-type="hard">

<reference-target provider-name="sap.com" target-type="application">

com.sap.portal.ivs.connectorservice

</reference-target>

</reference>

</application-j2ee-engine>

Thanks again... I really appreciate your help!

Cheers

Stuart

Former Member
0 Kudos

Hi again

I think I've found my silly mistake. I simply replaced:

IConnectorGatewayService cgService = (IConnectorGatewayService)ctx.lookup(IConnectorGatewayService.KEY);

with:

IConnectorGatewayService cgService = (IConnectorGatewayService)PortalRuntime.getRuntimeResources().getService(IConnectorGatewayService.KEY);

Now I get an error about invalid user credentials... which I think means I'm getting the service. Now the next hurdle... knowing how to restrict the EJB and associated web app to authenticated users. I guess this is all part of the learning process.

Thanks again for your help earlier. If you have any tips (or links) that may help on the security issues I'm going to look into, that would be great. If not... thanks for what you've helped with so far.

Cheers

Stuart

Vlado
Advisor
Advisor
0 Kudos

I can only add that in most cases it turns to be helpful to do a quick search on http://help.sap.com. For example, the IConnectorGatewayService usage above is described [here|http://help.sap.com/saphelp_nw70/helpdata/EN/89/8a185c148e4f6582560a8d809210b4/frameset.htm].

Authentication in the J2EE / Java EE world is usually done with login forms / login modules. You can also find information about that on the SAP help portal.

HTH!

\-- Vladimir