cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Enterprise Connector: Where to store login details?

Stefan-EA
Contributor
0 Kudos

I have a Java DC in Web AS 6.40 that needs to call a RFC from a R3 4.6C system. I used the wizard in the NWDS to generate the java proxy classes. Now I need to connect to the R3 system and all the examples I have seen hard code the login info inside a class as follows:

JCO.Client jcoclient =
		JCO.createClient(
			"100",			// SAP-Client
			"username",		// Username
			"password", 		// Password
			"en",			// Language
			"ECC host IP",		// Host IP
			"10");			// System No.

With multiple runtime systems like DEV, TEST and PROD, this wont work.

When calling RFCs from Web DynPro, all the login info is taken care of in the Web Dynpro Content Administrator (IE: "Maintain Jco Destinations"). Is there a way that my Java DC could leverage this? If I cant access this in the Java DC, where is the best place to store the login info? Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Stefan,

Can you tell us a bit more about your java DC? Where is it excuted? Is it a standalone application or is it run within the portal or j2ee server? Using JCa, you can utilise sso to connect to the backend system - assuming it's been configured (while getting the userid from the ume libraries). There might be a few options available depending on your architecture.

Cheers,

Dion

Stefan-EA
Contributor
0 Kudos

Hi Dion,

The Java DC is part of an application that is made up of a Java DC, EJB DC and an EAR DC, which resides on a 6.40 Web AS.

I ended up using the [Destination Service API|http://help.sap.com/saphelp_nw04/helpdata/en/17/d609b48ea5f748b47c0f32be265935/frameset.htm] and created an RFC destination in Visual Administrator to establish the connection.

I then used the following [code |http://help.sap.com/saphelp_nw04/helpdata/en/17/d609b48ea5f748b47c0f32be265935/frameset.htm]to connect to the RFC Destination in my Java DC

DestinationService dstService = (DestinationService) 
    ctx.lookup(DestinationService.JNDI_KEY);
    
    if (dstService == null)
        throw new NamingException("Destination Service not available");
    

    RFCDestination dst =
        (RFCDestination) dstService.getDestination("RFC", "dst-2");
    int maxPoolSize = dst.getMaxPoolSize();
    long maxWaitTime = dst.getMaxWaitTime();
    Properties jcoProperties = dst.getJCoProperties();

/**
* Code example for establishing a direct connection
*/
    JCO.Client client = JCO.createClient(jcoProperties);
    client.connect();
    client.ping();
    client.disconnect();

I had to add to add the following DCs from the SAP_JTECHS SC to the Java DC

u2022 com.sap.aii.proxy.framework

u2022 com.sap.aii.util.misc

and the following DCs from the SAP_JEE SC

u2022 com.sap.mw.jco

u2022 com.sap.exception

u2022 com.sap.security.api.sda

u2022 security.class

u2022 tc/sec/destinations/interface

Finally, in the EARs application-j2ee-engine.xml I added the following references:

<reference

reference-type="weak">

<reference-target

provider-name="sap.com"

target-type="interface">tc/sec/destinations/interface</reference-target>

</reference>

<reference

reference-type="weak">

<reference-target

provider-name="sap.com"

target-type="library">com.sap.mw.jco</reference-target>

</reference>

<reference

reference-type="hard">

<reference-target

provider-name="sap.com"

target-type="library">com.sap.aii.proxy.framework</reference-target>

</reference>

Im going to write up blog with a complete example on how to do this.

Former Member
0 Kudos

Hi Stefan,

good solution, will definitely come in handy sometime in the future. Thanks for letting us know how you solved it.

Cheers,

Dion

Stefan-EA
Contributor
0 Kudos

Here is the link to the [blog|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/10300] [original link is broken] [original link is broken] [original link is broken]; I wrote.

Answers (0)