Can A Web Service Take An Abstract Class As A Parameter?
I am new to J2EE and web services so please excuse me if I am clumsy with my terminology.
I am developing a web service using JAX-WS. I want the parameter to be an abstract class because I want to pass a composite object (composite pattern). The parameter should be the abstract component class so I can pass either a node or a leaf. Is this possible?
I have tried two methods already:
1) Implement the composite classes in a seperate package called "myserver.messages" that both the client and server use.
2) Put the composite's class implementations directly in the server source and try to get the client to generate all of the class artifacts for the composite (component, leaf and composite classes).
I am using NetBeans 5.5 to generate my client and the artifacts used to connect to the web service.
In both cases I end up with only the abstract component class artifact being generated. I cannot pass the concrete leaf or composite object to the web service operation. The first case gives me an error because the parameter is defined as an abstract class from the client package and the parameter that Im actually passing was from the myserver.messages pacakge. The second case gives me an error because it doesn't know what the leaf and composite classes are that Im trying to instantiate.
Id be happy to clarify if I was unclear. If anyone happens to know where reference material related to this question may be then please let me know. Thanks in advance!
Justin
[1531 byte] By [
jphilli9a] at [2007-11-27 5:32:02]

# 8
My issue is about passing a Java Object to web service operation as parameter.
When I code the webservice operation to accept java class object as parameter, the webservice project is not getting deployed (It complies). I Use Netbeans 5.5 and Sun Java System Application Server 9.
I get the message ?b>Problem encountered during annotation processing?/b> in Application server console. If I change, the paramenter to ArrayList or string it gets deployed.
Please find the webservice code with annotation and Transfer object . Hope that some body had experinced the same before. Please advice.
import to.TestTO;
import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@Stateless()
@WebService()
public class TestTOWS {
/**
* Web service operation
*/
@WebMethod
public String addTestToByObject(@WebParam(name = "testTo") TestTO testTo) {
// TODO implement operation
System.out.println("Inside addTestToByObject");
return testTo.getName();
}
}
Here is the transfer object JavaBean.
package to;
public class TestTO {
/** Creates a new instance of TestTO */
public TestTO() {
}
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Here is the Log
Problem encountered during annotation processing;
see stacktrace below for more information.
java.lang.NullPointerException
at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.isSubtype(WebServiceAP.java:418)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.isRemote(WebServiceAP.java:413)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.isLegalType(WebServiceVisitor.java:817)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.isLegalParameter(WebServiceVisitor.java:710)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.isLegalMethod(WebServiceVisitor.java:669)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.methodsAreLegal(WebServiceVisitor.java:624)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.isLegalImplementation(WebServiceVisitor.java:542)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.shouldProcessWebService(WebServiceVisitor.java:352)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.visitClassDeclaration(WebServiceVisitor.java:145)
at com.sun.tools.apt.mirror.declaration.ClassDeclarationImpl.accept(ClassDeclarationImpl.java:95)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.buildModel(WebServiceAP.java:347)
at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.process(WebServiceAP.java:232)
at com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationProcessor.process(AnnotationProcessors.java:60)
at com.sun.tools.apt.comp.Apt.main(Apt.java:454)
at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java:448)
at com.sun.tools.apt.main.Main.compile(Main.java:1075)
at com.sun.tools.apt.main.Main.compile(Main.java:938)
at com.sun.tools.apt.Main.processing(Main.java:95)
at com.sun.tools.apt.Main.process(Main.java:85)
at com.sun.tools.apt.Main.process(Main.java:67)
at com.sun.tools.ws.wscompile.CompileTool.buildModel(CompileTool.java:605)
at com.sun.tools.ws.wscompile.CompileTool.run(CompileTool.java:538)
at com.sun.tools.ws.util.ToolBase.run(ToolBase.java:56)
at com.sun.tools.ws.util.WSToolsObjectFactoryImpl.wsgen(WSToolsObjectFactoryImpl.java:44)
at com.sun.enterprise.webservice.WsUtil.runWsGen(WsUtil.java:1820)
at com.sun.enterprise.webservice.WsUtil.genWSInfo(WsUtil.java:2089)
at com.sun.enterprise.deployment.backend.ModuleDeployer.loadDescriptors(ModuleDeployer.java:396)
at com.sun.enterprise.deployment.backend.EjbModuleDeployer.deploy(EjbModuleDeployer.java:138)
at com.sun.enterprise.deployment.backend.ModuleDeployer.doRequestFinish(ModuleDeployer.java:160)
at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:169)
at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:95)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:871)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:266)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:739)
at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:174)
at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:210)
error: compilation failed, errors should have been reported
wsgen successful
wsgen successful
Message was edited by:
ahamedkabir_SCR
Message was edited by:
ahamedkabir_SCR
Message was edited by:
ahamedkabir_SCR
Message was edited by:
ahamedkabir_SCR