cancel
Showing results for 
Search instead for 
Did you mean: 

RFC Destination in WAS sp12

Former Member
0 Kudos

Hi All,

I am using WAS 6.4 with sp12 which supports RFC destination.

I have created a EJb which is internally using JCo to connect to SAP R/3. I am using RFC Destination for passing login information to SAP R/3. I have exposed this EJb as web service.

Now in EJb i have following code

InitialContext ctx = new InitialContext();

<b>

obj = ctx.lookup(DestinationService.JNDI_KEY);

DestinationService dstService = (DestinationService) obj;

RFCDestination dst = (RFCDestination) dstService.getDestination("RFC", "<System ID>");

Properties jcoProperties = dst.getJCoProperties();

JCO.Client client = JCO.createClient(jcoProperties);</b>

But when i execute the code it give Exeception in EJb that in could not type cast the obj into DestinationService Object. when i check the Object return by ctx.lookup it is of type <i>proxy</i>

I have taken above code from the location

http://help.sap.com/saphelp_nw04/helpdata/en/17/d609b48ea5f748b47c0f32be265935/content.htm

Why am not able to type cast the object?.

Accepted Solutions (1)

Accepted Solutions (1)

martijndeboer
Advisor
Advisor
0 Kudos

Hi,

I was not able to reproduce the error you described.

Here is what I did:

1) Create an EJB that has two methods. One lists the RFC destinations and another one calls ping on a destination.

2) Exposed the EJB as ws with basic authentication and SAP logon ticket support (->needed if you want to use tickets for authentication in the RFC destination)

3) called the ws from the wsnavigator (http://<host>:<port>/wsnavigator

You can find the projects here: http://sapmats-de.sap-ag.de/download/download.cgi?id=NWQP1N1WWSFUE3A0XAWJ7XXVDGOGET3P1FAP2OD81ZDWFLW...

Things that might have gone wrong with your project:

1) Missing reference to service tc/sec/destinations/service

2) When working with an older IDE and directly referencing the tc_sec_destinations_interface.jar from your EJB project instead of using "Add/Remove addtional libraries" from the projects context menu. This would cause classloader problems.

Regards,

Martijn de Boer

Former Member
0 Kudos

Thanks you very much.

The problem is solved. The problem was Missing reference to service tc/sec/destinations/service.

Thanks alot.

I wanted know about configuring RFC destination in Visual Administrator, here i can see a radio button with caption <b>"current User"</b> and <b>"Repository Authentication"</b>.

martijndeboer
Advisor
Advisor
0 Kudos

Hi,

When selecting "Current User", an SAP logon ticket will be sent for authentication. In some situations a user may not have sufficient permissions for retrieving information about ABAP structures etc. from the repository.

In that case, a different user for authentication at the repository should be used. Currently JCO does not support a different authentication at the repository using the data supplied by the UI (will be corrected with SP14). So my recommendation would be leave the fields "Repository Authentication" empty. In that case the currently authenticated user will be used for repository access.

If you need a different user to access the repository, create a second RFC destination for the repository and use that.

Regards,

Martijn de Boer

Former Member
0 Kudos

Hi DivyaKumar,

Could u pls let me know where this tc/sec/destinations/service is available.

I am using SAP web As 6.40 NW03 Sp 13

martijndeboer
Advisor
Advisor
0 Kudos

Hi,

the service is available in J2EE engine. To use RFC destinations, you need SP12 or higher.

A UI for administrating destinations is available inside the Visual Administrator (service "Destination Service").

The API for retrieving a set of properties usable to create a JCO.Client with example coding is available from http://help.sap.com/saphelp_nw04/helpdata/en/17/d609b48ea5f748b47c0f32be265935/frameset.htm

Regards,

Martijn de Boer

Answers (1)

Answers (1)

martijndeboer
Advisor
Advisor
0 Kudos

Hi,

As the destination service implements a remote service, you need to set a context classloader to explicitly tell the appserver to use the classes referenced by your application.

The coding for that is:


ClassLoader old_context_classloader =
	Thread.currentThread().getContextClassLoader();
try {
	Thread.currentThread().setContextClassLoader(
		this.getClass().getClassLoader());
	InitialContext ctx = new InitialContext();
        obj = ctx.lookup(DestinationService.JNDI_KEY);
        DestinationService dstService = (DestinationService) obj;


} finally {
	Thread.currentThread().setContextClassLoader(old_context_classloader);
}

Regards,

Martijn de Boer

Former Member
0 Kudos

Hi,

Thanks for the reply but it did not helped.I am getting same error.

martijndeboer
Advisor
Advisor
0 Kudos

Hi,

Can you please post the classloader references you have set in application-j2ee.xml?

Regards,

Martijn