cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Casting Problems Remote to Custom Object

Former Member
0 Likes
598

Hello Experts,

i have a problem with casting a javax.rmi.Remote -Object into an object that extends com.sap.engine.services.webservices.jaxrpc.encoding.GeneratedComplexType. I searched already in the Sun API or in SAP Java API. But i didn't find a hint how to cast the Remote object in my own one.

I'm want to consume a WebService in my app. According to the Tutorial on this link: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/0cac0dea-0d01-0010-edb4-8c7b068f...

But the Service does not answer with the right object. I only receive this javax.rmi.Remote Interface Object.

What do i have to do to cast this Remote Object into the described object?

I would be very happy to get an answer on that!!!

Thanks for the help!!!

Best Regards Philipp

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Hello Denis,

i just received a ClassCastException, nothing else ...

There is nothing in the StackTrace.


MyWebService myws = WebserviceConnection.initiate();
Remote remObj = myws.getLogicalPort(logicalPorts<i>,logReq.getClass());
logReq = (LoginRequest) remObj;

--> Here i get the Exception

The whole method is surrounded by an try-catch-block!

I think it's more a programming skill thing than a technical problem.

Best Regards

Philipp

Former Member
0 Likes

Check if <i>logReq.getClass()</i> returns class <i>LoginRequest</i>.

Former Member
0 Likes

Good Morning Denis,

i checked if

logReq.getClass()

returns the Class

LoginRequest

and it does.

I'm now trying to implement the Remote interface to my custom-class. We will see if it works. If you have some idea please respond.

Thanks for the help.

Philipp

Former Member
0 Likes

It's a pity. The java.rmi.Remote - Interface is not a valid interface for the usage in a proxy.

I'm always interested in new ideas....

Best Regards Philipp

Former Member
0 Likes

1. proxy is generated by NWDS - u should NOT change it

2. there should be apropriate method to get logical port without specifying name and class - try them first

so study generated classes carefully.

Former Member
0 Likes

Hello Denis,

1. i didn't touch the proxy.

2. There is no method: webservice.getlogicalPort() ; there is only on that has the input parameter Class to specify the called object. But i don't get the right object, i just get a java.rmi.Remote-Object. And if i try to cast it into the right one according to the Tutorial, i receive a classcastexception.

I tried to call on of these methodes with and without logicalportname but without success...

Any hints?

Best Regards Philipp

ravi_raman2
Active Contributor
0 Likes

hi,

Can u add the below lines after the catch line.

catch(Exception e ){

if(e.getMessage() != null){

System.out.println("Exception message is ::"+e.getMessage() );

}

if(e.getCause() != null){

System.out.println("Cause of the exception is ::"+e.getCause() );

}

See if that prints out a bit more...

Hope it helps

Regards

Ravi

Former Member
0 Likes

Hello Ravi,

I get the following message:

Caught Exception: class java.lang.ClassCastException

Message: null

Cause: null

It doesn't make any sense to me that i don't get any messages from the Exception!!

I hope you a hint....

Best Regards

Philipp

Former Member
0 Likes

I found out that the object i receive from the Proxy is a BindingStub Object, that implements Remote....

But i still have the problem that it is impossible to cast this object in another object.

I really don't know what i could do right now!??!??!

Thanks for the help!!

Best Regards Philipp

Former Member
0 Likes

The remObj is not type of LoginRequest.

If you want to prove it, put the following lines before the casting.


If ( remObj instanceof LoginRequest )
{
     // do something
}

You may need to find other ways to get what you want.

Dennis

Former Member
0 Likes

Hello Dennis,

Thanks for the answer....

But i already know that i don't get a LoginRequest Object from my Web Service.

The Web service just returns a WebServiceNameBindingStub, this object is not castable in a LoginRequest.

My program creates a LoginRequest with the default constructor and i get the following messages:

<i>Class of LoginRequest: com.xxx.xxx.conn.proxy.types.p2.LoginRequest

HashCode of LoginRequest:21676906

LoginRequest To String: mappingInfo: auth Auth false false 11 language Language false false 11 version Version false false 11 application Application false false 00 </i>

For the Remote Object i get the following message:

<i>Class of RemoteObject: class com.xxx.xxx.conn.proxy.WebServiceNameBindingStub

HashCode of the RemoteObject: 23296339</i>

After the cast from the Remote-Object to the LoginRequest i get the following message:

<i>Caught Exception: class java.lang.ClassCastException

Message: null

Cause: null</i>

I hope that explains the situation a bit better

Message was edited by:

Philipp Kostyra

Answers (1)

Answers (1)

Former Member
0 Likes

Could u please post detailed stack trace?