You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by ronanf <ro...@yahoo.com> on 2008/01/28 19:49:29 UTC
List parameters appearing with no entries on server side
Hi,
I'd really appreciate any help with this one.
I am using WSDL-first sevice creation. I'm having a problem whereby an
object I set in a List parameter on the client side does not show up on the
server side. Instead on the server side I just see an empty List.
So the service method signature is as follows:
public String createMsg(String parentFolderId, MsgHolder msgHolder,
List<MsgContentHolder> contentList)
where MsgHolder and MsgContentHolder are my own types.
The client code calls this method with one object in the contentList
parameter. But when the call gets through to the server side the content
list is empty.
My WSDL for the operation is:
<xs:element name="createMsg" type="types:createMsg"/>
<xs:complexType name="createMsg">
<xs:sequence>
<xs:element minOccurs="0" name="parentFolderId"
type="xs:string"/>
<xs:element minOccurs="0" name="msgHolder"
type="wsxsd:MsgHolder"/>
<xs:element maxOccurs="unbounded" minOccurs="0"
name="cContentList" type="wsxsd:MsgContentHolder"/>
</xs:sequence>
</xs:complexType>
<xs:element name="createMsgResponse" type="types:createMsgResponse"/>
<xs:complexType name="createMsgResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
And the xsd definition for MsgContentHolder is:
<xs:complexType name="MsgContentHolder">
<xs:sequence>
<xs:element minOccurs="0" name="msgId" type="xs:string"/>
<xs:element minOccurs="0" name="content" type="xs:string"/>
<xs:element minOccurs="0" name="contentFilename"
type="xs:string"/>
<xs:element minOccurs="0" name="contentId" type="xs:string"/>
<xs:element minOccurs="0" name="ianaMimeType" type="xs:string"/>
<xs:element minOccurs="0" name="msgDirection" type="xs:string"/>
<xs:element minOccurs="0" name="msgTypeName" type="xs:string"/>
</xs:sequence>
</xs:complexType>
Thanks,
Ronan
--
View this message in context: http://www.nabble.com/List-parameters-appearing-with-no-entries-on-server-side-tp15142470p15142470.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: List parameters appearing with no entries on server side
Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday 30 January 2008, ronanf wrote:
> Yes I am running CXF 2.0.3.
>
> In the end my problem was I have an asm1*.jar in my build path (this
> is needed for the version of Hibernate I'm running). But CXF requires
> asm2* or asm3* as you pointed out.
>
> So if I include asm1 on my server program and asm2 on my client then I
> don't get the problem anymore. That is to say the Lists are populated
> correctly when sent by the client.
>
> Does version 2.0.4 of CXF aslo rely on asm to solve this problem?
No. 2.0.4 fixes the reflection based processing to make it work
correctly. That said, the asm version is very slightly faster, but
probably not noticable for most cases.
--
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog
Re: List parameters appearing with no entries on server side
Posted by Ian Roberts <i....@dcs.shef.ac.uk>.
ronanf wrote:
> Thanks for that Dan,
>
> Yes I am running CXF 2.0.3.
>
> In the end my problem was I have an asm1*.jar in my build path (this is
> needed for the version of Hibernate I'm running). But CXF requires asm2* or
> asm3* as you pointed out.
I got around this by using the cglib-nodep JAR with Hibernate, which
includes its own internal copy of the ASM classes under a different
package name and can happily co-exist with another version of ASM on the
classpath.
Ian
--
Ian Roberts | Department of Computer Science
i.roberts@dcs.shef.ac.uk | University of Sheffield, UK
Re: List parameters appearing with no entries on server side
Posted by ronanf <ro...@yahoo.com>.
Thanks for that Dan,
Yes I am running CXF 2.0.3.
In the end my problem was I have an asm1*.jar in my build path (this is
needed for the version of Hibernate I'm running). But CXF requires asm2* or
asm3* as you pointed out.
So if I include asm1 on my server program and asm2 on my client then I don't
get the problem anymore. That is to say the Lists are populated correctly
when sent by the client.
Does version 2.0.4 of CXF aslo rely on asm to solve this problem?
Thanks,
Ronan
--
View this message in context: http://www.nabble.com/List-parameters-appearing-with-no-entries-on-server-side-tp15142470p15188023.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: List parameters appearing with no entries on server side
Posted by Daniel Kulp <dk...@apache.org>.
Ronan,
I assume you are using CXF 2.0.3... Any chance you can add an asm jar
to your classpath? Any asm 2.x or 3.x version should work. That will
flip the wrapper helper things over to an ASM version that works
correctly with the lists. The bug you are seeing is a bug in 2.0.3 if
ASM isn't available.
That said, it's also fixed in 2.0.4. 2.0.4 is now officially released.
I'm just waiting for web sites to sync around at apache before sending
the notice out. Download info is at:
http://cwiki.apache.org/confluence/display/CXF/Download
Dan
On Tuesday 29 January 2008, ronanf wrote:
> After further investigation the problem resides in the
> wsdl2Java-generated Java class for the operation.
> The class looks like this:
>
> /**
> * <p>Java class for createMsg complex type.
> *
> * <p>The following schema fragment specifies the expected content
> contained within this class.
> *
> * <pre>
> * <complexType name="createMsg">
> * <complexContent>
> * <restriction
> base="{http://www.w3.org/2001/XMLSchema}anyType"> *
> <sequence>
> * <element name="parentFolderId"
> type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
> * <element name="msgHolder"
> type="{http://ws.mstore.common.magoosoft.com/}MStoreMsgHolder"
> minOccurs="0"/>
> * <element name="cContentList"
> type="{http://ws.mstore.common.magoosoft.com/}MStoreMsgContentHolder"
> maxOccurs="unbounded" minOccurs="0"/>
> * <element name="cAttachmentList"
> type="{http://ws.mstore.common.magoosoft.com/}MStoreMsgAttachmentHolde
>r" maxOccurs="unbounded" minOccurs="0"/>
> * </sequence>
> * </restriction>
> * </complexContent>
> * </complexType>
> * </pre>
> *
> *
> */
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "createMsg", propOrder = {
> "parentFolderId",
> "msgHolder",
> "cContentList",
> "cAttachmentList"
> })
> public class CreateMsg {
>
> protected String parentFolderId;
> protected MStoreMsgHolder msgHolder;
> @XmlElement(required = true)
> protected List<MStoreMsgContentHolder> cContentList;
> @XmlElement(required = true)
> protected List<MStoreMsgAttachmentHolder> cAttachmentList;
>
> /**
> * Gets the value of the parentFolderId property.
> *
> * @return
> * possible object is
> * {@link String }
> *
> */
> public String getParentFolderId() {
> return parentFolderId;
> }
>
> /**
> * Sets the value of the parentFolderId property.
> *
> * @param value
> * allowed object is
> * {@link String }
> *
> */
> public void setParentFolderId(String value) {
> this.parentFolderId = value;
> }
>
> /**
> * Gets the value of the msgHolder property.
> *
> * @return
> * possible object is
> * {@link MStoreMsgHolder }
> *
> */
> public MStoreMsgHolder getMsgHolder() {
> return msgHolder;
> }
>
> /**
> * Sets the value of the msgHolder property.
> *
> * @param value
> * allowed object is
> * {@link MStoreMsgHolder }
> *
> */
> public void setMsgHolder(MStoreMsgHolder value) {
> this.msgHolder = value;
> }
>
> /**
> * Gets the value of the cContentList property.
> *
> * <p>
> * This accessor method returns a reference to the live list,
> * not a snapshot. Therefore any modification you make to the
> * returned list will be present inside the JAXB object.
> * This is why there is not a <CODE>set</CODE> method for the
> cContentList property.
> *
> * <p>
> * For example, to add a new item, do as follows:
> * <pre>
> * getCContentList().add(newItem);
> * </pre>
> *
> *
> * <p>
> * Objects of the following type(s) are allowed in the list
> * {@link MStoreMsgContentHolder }
> *
> *
> */
> public List<MStoreMsgContentHolder> getCContentList() {
> if (cContentList == null) {
> cContentList = new ArrayList<MStoreMsgContentHolder>();
> }
> return this.cContentList;
> }
>
> /**
> * Gets the value of the cAttachmentList property.
> *
> * <p>
> * This accessor method returns a reference to the live list,
> * not a snapshot. Therefore any modification you make to the
> * returned list will be present inside the JAXB object.
> * This is why there is not a <CODE>set</CODE> method for the
> cAttachmentList property.
> *
> * <p>
> * For example, to add a new item, do as follows:
> * <pre>
> * getCAttachmentList().add(newItem);
> * </pre>
> *
> *
> * <p>
> * Objects of the following type(s) are allowed in the list
> * {@link MStoreMsgAttachmentHolder }
> *
> *
> */
> public List<MStoreMsgAttachmentHolder> getCAttachmentList() {
> if (cAttachmentList == null) {
> cAttachmentList = new
> ArrayList<MStoreMsgAttachmentHolder>(); }
> return this.cAttachmentList;
> }
>
> }
>
>
> The problem occurs because when the client is calling the server the
> code in WrapperHelper.createWrapperObject() fails to add the Lists to
> the object because there is no setter and because there is no Field
> objects for the cContentList and cAttachmentList fields in
> WrapperHelper.fields.
>
> One temporary solution is simply to add setters to the generated class
> but they will be overwritten the next time the code is generated.
>
> Another solution is to add the name attribute to the List fields on
> CreateMsg like this:
>
> @XmlElement(name = "cContentList", required = true)
> protected List<MStoreMsgContentHolder> cContentList;
> @XmlElement(name = "cAttachmentList", required = true)
> protected List<MStoreMsgAttachmentHolder> cAttachmentList;
>
> This will cause WrapperHelper.createWrapperHelper() to correctly set
> the fields field so that the cContentList and cAttachmentList values
> get set correctly in WrapperHelper.createWrapperObject().
>
> But again this is not satifactory because the generated code will get
> overwritten.
>
> Is there some tag/attribute/property I can set in the WSDL to make the
> name attribute get written in the @XmlElement in the generated class?
>
> Regards,
> Ronan
--
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog
Re: List parameters appearing with no entries on server side
Posted by ronanf <ro...@yahoo.com>.
After further investigation the problem resides in the wsdl2Java-generated
Java class for the operation.
The class looks like this:
/**
* <p>Java class for createMsg complex type.
*
* <p>The following schema fragment specifies the expected content contained
within this class.
*
* <pre>
* <complexType name="createMsg">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="parentFolderId"
type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="msgHolder"
type="{http://ws.mstore.common.magoosoft.com/}MStoreMsgHolder"
minOccurs="0"/>
* <element name="cContentList"
type="{http://ws.mstore.common.magoosoft.com/}MStoreMsgContentHolder"
maxOccurs="unbounded" minOccurs="0"/>
* <element name="cAttachmentList"
type="{http://ws.mstore.common.magoosoft.com/}MStoreMsgAttachmentHolder"
maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "createMsg", propOrder = {
"parentFolderId",
"msgHolder",
"cContentList",
"cAttachmentList"
})
public class CreateMsg {
protected String parentFolderId;
protected MStoreMsgHolder msgHolder;
@XmlElement(required = true)
protected List<MStoreMsgContentHolder> cContentList;
@XmlElement(required = true)
protected List<MStoreMsgAttachmentHolder> cAttachmentList;
/**
* Gets the value of the parentFolderId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getParentFolderId() {
return parentFolderId;
}
/**
* Sets the value of the parentFolderId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setParentFolderId(String value) {
this.parentFolderId = value;
}
/**
* Gets the value of the msgHolder property.
*
* @return
* possible object is
* {@link MStoreMsgHolder }
*
*/
public MStoreMsgHolder getMsgHolder() {
return msgHolder;
}
/**
* Sets the value of the msgHolder property.
*
* @param value
* allowed object is
* {@link MStoreMsgHolder }
*
*/
public void setMsgHolder(MStoreMsgHolder value) {
this.msgHolder = value;
}
/**
* Gets the value of the cContentList property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the
cContentList property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getCContentList().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link MStoreMsgContentHolder }
*
*
*/
public List<MStoreMsgContentHolder> getCContentList() {
if (cContentList == null) {
cContentList = new ArrayList<MStoreMsgContentHolder>();
}
return this.cContentList;
}
/**
* Gets the value of the cAttachmentList property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the
cAttachmentList property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getCAttachmentList().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link MStoreMsgAttachmentHolder }
*
*
*/
public List<MStoreMsgAttachmentHolder> getCAttachmentList() {
if (cAttachmentList == null) {
cAttachmentList = new ArrayList<MStoreMsgAttachmentHolder>();
}
return this.cAttachmentList;
}
}
The problem occurs because when the client is calling the server the code in
WrapperHelper.createWrapperObject() fails to add the Lists to the object
because there is no setter and because there is no Field objects for the
cContentList and cAttachmentList fields in WrapperHelper.fields.
One temporary solution is simply to add setters to the generated class but
they will be overwritten the next time the code is generated.
Another solution is to add the name attribute to the List fields on
CreateMsg like this:
@XmlElement(name = "cContentList", required = true)
protected List<MStoreMsgContentHolder> cContentList;
@XmlElement(name = "cAttachmentList", required = true)
protected List<MStoreMsgAttachmentHolder> cAttachmentList;
This will cause WrapperHelper.createWrapperHelper() to correctly set the
fields field so that the cContentList and cAttachmentList values get set
correctly in WrapperHelper.createWrapperObject().
But again this is not satifactory because the generated code will get
overwritten.
Is there some tag/attribute/property I can set in the WSDL to make the name
attribute get written in the @XmlElement in the generated class?
Regards,
Ronan
--
View this message in context: http://www.nabble.com/List-parameters-appearing-with-no-entries-on-server-side-tp15142470p15164982.html
Sent from the cxf-user mailing list archive at Nabble.com.