returing INTERFACE from a SOAP service
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, October 20, 2003 08:36 AM

I'm stuck with a serious problem. let me go directly to the problem. This is my soap service "urn:server" pubilc A getMessage() { B b = new B(); b.setName("test"); return b; } And here's my client serializer = new BeanSerializer(); QName dataQName = new QName("urn:A","A"); registry.mapTypes(Constants.NS_URI_SOAP_ENC,dataQName,A.class, serializer, serializer); dataQName = new QName("urn:B","B"); registry.mapTypes(Constants.NS_URI_SOAP_ENC,dataQName,B.class, serializer, serializer); Call call = new Call(); call.setSOAPMappingRegistry(reg   More>>
I'm stuck with a serious problem. let me go directly to the problem.

This is my soap service

"urn:server"

			
pubilc A getMessage()
{
B b = new B();
b.setName("test");
return b;
}

And here's my client

serializer = new BeanSerializer();
QName dataQName = new QName("urn:A","A");
registry.mapTypes(Constants.NS_URI_SOAP_ENC,dataQName,A.class, serializer, serializer);

dataQName = new QName("urn:B","B");
registry.mapTypes(Constants.NS_URI_SOAP_ENC,dataQName,B.class, serializer, serializer);

Call call = new Call();
call.setSOAPMappingRegistry(registry);
call.setTargetObjectURI("urn:server");
call.setMethodName("getMessage");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

Response response = call.invoke(url,"");
A a = (A) response.getParameter().getValue();
B b = (B) a;

System.out.println(b.getName());

END....

Now please have a look at A and B


public interface A
{
public String getName();
public void setName();
}

public class B implements A
{
private String name;
public String getName()
{
return this.name;
}

public void setName(String name)
{
this.name = name;
}

}


Now the problem goes like this.....this is not working ;-)

It's giving the following error,

SOAPException: faultCode=SOAP-ENV:Client; msg=Unable to instantiate 'A': A; targetException= java.lang.IllegalArgumentException: Unable to instantiate 'A: A]
at org.apache.soap.rpc.Call.invoke(Call.java:246)
at Test.send(Test.java:69)
at Test.main(Test.java:93)



How can i return interfaces from a SOAP service ?
or what's the solution for this problem. ????





Thanks in advance.
Sreehari.    <<Less

Re: returing INTERFACE from a SOAP service

Posted By:   Simarjot_Singh  
Posted On:   Wednesday, October 29, 2003 11:25 PM

Hi Sreehari,


I dont think that there is any way by which we can do it because we cannot make object of the interface. Error clearly says that "Unable to instantiate 'A': A", where A is an interface.


I checked out your code. There are certain mistakes in it.


Firstly,

You have defined the method as "pubilc A getMessage(){..}", which should be spelled as "public A getMessage(){..}".


Second,

setName() method declared in interface does not take any argument whereas in class B it is taking argument as a string.


Third,

In client class you are using method getParameter() in statement

A a = (A) response.getParameter().getValue();>


but the correct statement should be:

A a = (A) response.getReturnValue().getValue();


I hope you must have ractified these mistakes by now.


Simarjot Singh
About | Sitemap | Contact