Hi,
Is it possible to pass subclasses as parameters like in JAXWS 2.x?
My issue is this:
I'm unable to get an Axis2 client to pass a subclass to a JAXWS web service
because although wsdl2java generates a the subclass (when using xmlbeans), I
can't seem to properly create an instance in order to pass it. Does anyone
know how to do this?
thanks...
The details:
I've created a test web service under JAXWS, which exposes a method with a
polymorphic parameter:
@WebService
@XmlSeeAlso(SubBean.class)
public class Hello {
@WebMethod testAbstractBeanArg(@WebParam AbstractBean bean) {...}
}
The @XmlSeeAlso annotation ensures the subclass SubBean also gets
represented in the WSDL:
<xs:complexType name="subBean">
<xs:complexContent>
<xs:extension base="tns:abstractBean">
<xs:sequence>
<xs:element name="desc" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
When I generate client-side code using JAXWS's wsimport, and invoke the
method, I get a SubBean class as expected.
When I generate client-side code using Axis2's wsdl2java (with xmlbeans), I
have no idea how to create an instance. Based on the tutorial and my
generated classes, I tried this:
TestAbstractBeanArgDocument req =
TestAbstractBeanArgDocument.Factory.newInstance();
SubBeanImpl bean = new SubBeanImpl(req.type);
bean.setDesc("sub bean desc");
req.addNewTestAbstractBeanArg().setArg0(bean);
TestAbstractBeanArgResponseDocument res =
stub.testAbstractBeanArg(req);
System.out.println(res.getTestAbstractBeanArgResponse().getReturn());
This throws the following exception inside the setDesc method:
java.lang.NullPointerException
at ws.impl.SubBeanImpl.setDesc(SubBeanImpl.java:79)
at samples.quickstart.clients.ADBClient.test(ADBClient.java:59)
at samples.quickstart.clients.ADBClient.main(ADBClient.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:202)
at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:134)
at org.apache.tools.ant.taskdefs.Java.run(Java.java:710)
at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:178)
at org.apache.tools.ant.taskdefs.Java.execute(Java.java:84)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at
org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:240)
at
org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:293)
at
org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:131)
the line that causes the exception is the one in bold below:
public void setDesc(java.lang.String desc)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.SimpleValue target = null;
target =
(org.apache.xmlbeans.SimpleValue)get_store().find_element_user(DESC$0, 0);
if (target == null)
{
target =
(org.apache.xmlbeans.SimpleValue)get_store().add_element_user(DESC$0);
}
target.setStringValue(desc);
}
}
--
View this message in context:
http://www.nabble.com/Passing-subclasses-in-method-parameters-tp19705964p19705964.html
Sent from the Axis - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]