Dan,
It could be that this discussion bears on a problem I've been having
trouble with: I have a client implemented like this:
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(MyInterface.class);
factory.setAddress(wsdlstr);
factory.getServiceFactory().setDataBinding(new
AegisDatabinding());
myIf = (MyInterface) factory.create();
When I call one of the MyInterface methods a SOAP request is created and
sent to the endpoint, which processes it correctly and sends a SOAP
response. I can see the response being received, and we can see that
its contents correctly describe the complex object being returned, but
when the client method returns -- by which time it should have marshaled
the object from the SOAP -- I get null.
I have many other WS calls that work just fine using this method of
setting up the client, with a whole variety of objects being passed
back-and-forth between client and server. I'm at something of a loss as
to how to debug this. I've tried setting the logger for
"org.apache.cxf" to "debug", but nothing interesting shows up (lots of
"Mapping file... not found" logs, but I always get those, even when
everything works). I tried stepping into the invocation chain in the
Eclipse debugger, having associated the Aegis source code zip file with
the library, but although it allows me to see the code, for some reason
Eclipse refuses to let me evaluate any values in the Aegis stack frames.
Do you think this is related to your statements about
"jaxb.additionalContextClasses"? I don't claim to understand what you
wrote, but your mention of returning a null if something isn't done just
so caught my attention.
I'd appreciate any advice -- I'm a bit stuck right now.
Michael
-----Original Message-----
From: Daniel Kulp [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 26, 2008 11:08 PM
To: [email protected]
Cc: Rahul Dev
Subject: Re: Custom Classes
I copy/pasted your code into one of my test projects and it pretty much
just
worked. Note: you need to add the jaxb.additionalContextClasses on the
client side as well, otherwise you just get "null" back.
Quick question: do you have the asm jar on the classpath? Looking at
the
stack trace, I assume no. Try adding it.
Dan
On Monday 25 August 2008 6:07:14 am Rahul Dev wrote:
> Hi
>
> Your suggestion works to an extent, but the following codebase still
gives
> problems:
>
> public class Company implements Serializable {
>
> private static final long serialVersionUID = 1L;
> public String gid;
> public String Name;
>
> }
>
> public class Employee implements Serializable {
>
> private static final long serialVersionUID = 1L;
> public String gid;
> public String lastName;
> public String firstName;
> public Set<String> privileges;
>
> }
>
> @WebService
> public interface AuthService {
>
> //Can contain any serializable class
> public List getAnyClass(@WebParam(name = "gid")String gid);
> }
>
> @WebService(endpointInterface =
"com.company.auth.service.AuthService",
> serviceName = "corporateAuthService") public class AuthServiceImpl
> implements AuthService {
>
> public List getAnyClass(String gid) {
> List Ret = new ArrayList();
>
> Employee EmployeeObj = new Employee();
> EmployeeObj.gid = gid;
> EmployeeObj.lastName = "bond";
> EmployeeObj.firstName = "james";
> Ret.add(EmployeeObj);
>
> Company CompanyObj = new Company();
> CompanyObj.gid = gid;
> CompanyObj.Name = "MI5";
> Ret.add(EmployeeObj);
>
> return Ret;
> }
>
> }
>
> public class Server {
>
> public static void main(String[] args) {
> AuthServiceImpl implementor = new AuthServiceImpl();
> JaxWsServerFactoryBean svrFactory = new
JaxWsServerFactoryBean();
> svrFactory.setServiceClass(AuthService.class);
> svrFactory.setAddress("http://localhost:9000/authService");
> svrFactory.setServiceBean(implementor);
> svrFactory.getInInterceptors().add(new
LoggingInInterceptor());
> svrFactory.getOutInterceptors().add(new
LoggingOutInterceptor());
>
> //Define the serializable classes
> Class classes[] = new Class[] {Employee.class, Company.class};
> HashMap props = new HashMap();
> props.put("jaxb.additionalContextClasses", classes);
> svrFactory.setProperties(props);
> svrFactory.create();
> }
> }
>
> public final class Client {
>
> private Client() {
> }
>
> public static void main(String args[]) throws Exception {
>
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>
> factory.getInInterceptors().add(new LoggingInInterceptor());
> factory.getOutInterceptors().add(new LoggingOutInterceptor());
> factory.setServiceClass(AuthService.class);
> factory.setAddress("http://localhost:9000/authService");
> AuthService client = (AuthService) factory.create();
>
> List Employees = client.getAnyClass("0223938");
> System.out.println("Server said: " + Employees.size());
> System.exit(0);
>
> }
>
> }
>
> I get the following exception:
> org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected
element
> (uri:"", local:"return"). Expected elements are (none) at
>
org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
a:5
>52) at
>
org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
a:4
>65) at
org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:105)
> at
>
org.apache.cxf.interceptor.DocLiteralInInterceptor.getPara(DocLiteralInI
nte
>rceptor.java:235) at
>
org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLite
ral
>InInterceptor.java:120) at
>
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC
hai
>n.java:220) at
> org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:449) at
>
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResp
ons
>e(HTTPConduit.java:2029) at
>
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTP
Con
>duit.java:1865) at
>
org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutpu
tSt
>ream.java:47) at
>
org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:170)
at
>
org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
at
> org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:593)
at
>
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingI
nte
>rceptor.handleMessage(MessageSenderInterceptor.java:62) at
>
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC
hai
>n.java:220) at
> org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:296) at
> org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:242) at
> org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) at
>
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:178)
at
> $Proxy33.getAnyClass(Unknown Source)
> at com.company.auth.client.Client.main(Client.java:26)
>
> Kindly advice.
>
> Thanks
> Rahul
>
> Daniel Kulp <[EMAIL PROTECTED]> wrote:
> Are you using ServerFactoryBean or are you using a JAX-WS
> style "Endpoint.publish"?
>
> Basically, you need to set the property:
> jaxb.additionalContextClasses
> to a Class[].
>
> For that ServerFactoryBean stuff, just call:
> Class classes[] = .......
> bean.getProperties().put("jaxb.additionalContextClasses"
> classes);
> before you call create().
>
>
> For the other case, I'm not sure, but I think you do:
> Endpoint ep = Endpoint.create(....);
> ep.setProperty("jaxb.additionalContextClasses"
> classes);
> ep.publish(...);
>
>
> Alternatively, we do have samples in the docs on how to set the
databinding
> programmaticly (look in the Aegis databinding section). You can
create
> your own instance of JAXBDataBinding, call the setAdditionalClass(...)
> method, set that into the factory, etc....
>
> Dan
>
> On Wednesday 20 August 2008 1:12:17 am Rahul Dev wrote:
> > Thanks Dan for your mail.
> >
> > The server is started as a standalone server. Is there a way by
which we
> > can use API's to register these 55 classes manually inside the
standalone
> > source code?
> >
> > Managing external XML files for these would be difficult from a
> > maintenance point.
> >
> > We are dynamically detecting the classes during bootup and would
like to
> > have all these classes dynamically loaded.
> >
> > Rahul
> >
> > Daniel Kulp wrote:
> > Are you talking about JAXB databinding?
> >
> > If so, there are a couple options:
> >
> > 1) Add the XmlSeeAlso annotation to the interface and point it at
all 55
> > classes.
> >
> > 2) If at least one class in the package containing the 55 classes is
> > picked up via a parameter on another method or something, you can
put a
> > jaxb.index file in the package that is just a list of all the class
names
> > (minus the package).
> >
> > 3) There is also a jaxb.extraclasses property that can be added to
the
> > configuration of the endpoint to have it load additional classes.
See:
> >
http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/resources/ex
t
> >ra jaxbclass.xml
> >
> > Dan
> >
> > On Tuesday 19 August 2008 11:43:15 am Rahul Dev wrote:
> > > Hi,
> > >
> > > I have a WS interface that looks like this
> > > public List getResults(Date FromDate, Date ToDate);
> > >
> > > The problem is that List can return any of the 55 java pojo model
> > > classes that we have defined. None of these implement any
interface
> > > either.
> > >
> > > When I generate WSDL, I would like all these 55 classes to appear
in
> > > the XSD so that the client can recognize them.
> > >
> > > Because the return type is List and the list can contain any
object
> > > that implements Serializable, the client can never know what
objects
> > > can come.
> > >
> > > Is there a way by which I can define these 55 custom classes?
> > > Rahul
--
Daniel Kulp
[EMAIL PROTECTED]
http://www.dankulp.com/blog
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________