Re: [Simple-support] Inner ElementList issue with WCF REST Service Response
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2011-03-16 10:35:00
|
Yep...
--- On Tue, 15/3/11, Alexander Shchegolev <ir...@gm...> wrote:
From: Alexander Shchegolev <ir...@gm...>
Subject: Re: [Simple-support] Inner ElementList issue with WCF REST Service Response
To: "Pinakin Shah" <pi...@gm...>
Cc: "sim...@li..." <sim...@li...>
Received: Tuesday, 15 March, 2011, 1:09 AM
Set required=false for the ElementList. Otherwise it always fails on empty lists.
С уважением, Александр Щеголев.
15.03.2011, в 10:04, Pinakin Shah <pi...@gm...> написал(а):
Hello,
We are using the simple framework 2.4.1 in Android to deserialize the WCF REST service response. We are using the WCF Bare response format, which do not have a enclosing parent tag in the response xml. It works well as long as the WCF returns atleast one record in response but gives the following error if the search do not fetch any records. Please help
org.simpleframework.xml.core.ValueRequiredException: Unable to satisfy @org.simpleframework.xml.ElementList(data=false, empty=true, entry=, inline=true, name=, required=true, type=void) on field 'list' public java.util.List com.realtyradar.mobile.PropertySearchResult.list for class com.realtyradar.mobile.PropertySearchResult at line -1
Below is the code and xml responses from WCF
package com.realtyradar.mobile;
import java.util.List;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Namespace;
import org.simpleframework.xml.NamespaceList;
import org.simpleframework.xml.Root;
@Root(name = "ArrayOfmob_searchpropertiesbybudget_Result", strict=false)
@NamespaceList({
@Namespace(reference = "http://schemas.datacontract.org/2004/07/RealtyRadarMobileService"),
//@Namespace(reference = "http://schemas.datacontract.org/2004/07/RealtyRadarMobileService", prefix = "i") })
@Namespace(reference = "http://www.w3.org/2001/XMLSchema-instance", prefix = "i") })
public class PropertySearchResult {
@ElementList( inline=true)
public List<Property> list ;
// public PropertySearchResult(@ElementList(inline = true,entry="mob_searchpropertiesbybudget_Result") List<Property> list) {
// this.list = list;
// }
public List<Property> getList() {
return this.list;
}
}
@Root(name = "mob_searchpropertiesbybudget_Result")
@Namespace(reference = "http://schemas.microsoft.com/2003/10/Serialization/", prefix = "z")
class Property
{
@Attribute
@Namespace(reference = "http://schemas.microsoft.com/2003/10/Serialization/", prefix="z")
private String Id;
public String getId()
{return Id;}
@Element(name = "BrokerEmail",required=false)
private String BrokerEmail;
public String getBrokerEmail() {
return BrokerEmail;
}
@Element(name = "BrokerMobile",required=false)
private String BrokerMobile;
public String getBrokerMobile() {
return BrokerMobile;
}
@Element(name = "BrokerName", required = false)
private String BrokerName;
public String getBrokerName() {
return BrokerName;
}
@Element(name ="BuildingAddress",required=false)
private String BuildingAddress;
public String getBudildingAddress(){
return BuildingAddress;
}
@Element(name = "Buildingname",required=false)
private String Buildingname;
public String getBuildingname() {
return Buildingname;
}
@Element(name = "ClientEmail",required=false)
private String ClientEmail;
public String getClientEmail() {
return ClientEmail;
}
@Element(name = "ClientMobile", required = false)
private String ClientMobile;
public String getClientMobile() {
return ClientMobile;
}
@Element(name = "ClientName", required = false)
private String ClientName;
public String getClientName() {
return ClientName;
}
@Element(name ="PropertyId")
private String PropertyId;
public String getPropertyId(){
return PropertyId;
}
@Element(name ="area",required=false)
private String area;
public String getarea(){
return area;
}
@Element(name = "date",required=false)
private String date;
public String getdate (){
return date;
}
@Element(name = "price",required=false)
private String price;
public String getPrice() {
return price;
}
@Element(name = "propertytitle", required = false)
private String propertytitle;
public String getPropertyTitle() {
return propertytitle;
}
public Property(
@Attribute(name="Id") @Namespace(reference = "http://schemas.microsoft.com/2003/10/Serialization/", prefix="z") String Id,
@Element(name = "BrokerEmail",required=false) String BrokerEmail,
@Element(name = "BrokerMobile",required=false) String BrokerMobile,
@Element(name = "BrokerName", required = false) String BrokerName,
@Element(name = "BuildingAddress",required=false) String BuildingAddress,
@Element(name = "Buildingname",required=false) String Buildingname,
@Element(name = "ClientEmail",required=false) String ClientEmail,
@Element(name = "ClientMobile", required = false) String ClientMobile,
@Element(name = "ClientName",required = false) String ClientName,
@Element(name = "PropertyId") String PropertyId,
@Element(name = "area",required=false) String area,
@Element(name = "date",required=false) String date,
@Element(name = "price",required=false) String price,
@Element(name="propertytitle",required=false)String propertytitle)
{
this.Id=Id;
this.BrokerEmail=BrokerEmail;
this.BrokerMobile=BrokerMobile;
this.BrokerName=BrokerName;
this.BuildingAddress=BuildingAddress;
this.Buildingname=Buildingname;
this.ClientEmail=ClientEmail;
this.ClientMobile=ClientMobile;
this.ClientName=ClientName;
this.PropertyId=PropertyId;
this.area=area;
this.date=date;
this.price=price;
this.propertytitle=propertytitle;
}
}
With Data in search
<ArrayOfmob_searchpropertiesbybudget_Result xmlns="http://schemas.datacontract.org/2004/07/RealtyRadarMobileService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<mob_searchpropertiesbybudget_Result z:Id="i1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
<BrokerEmail i:nil="true" />
<BrokerMobile i:nil="true" />
<BrokerName i:nil="true" />
<BuildingAddress>ALAKNANDA SOCIETY</BuildingAddress>
<Buildingname>ALAKNANDA SOCIETY</Buildingname>
<ClientEmail />
<ClientMobile />
<ClientName>S P Thakur [98334 46831]</ClientName>
<PropertyId>1</PropertyId>
<area>2000</area>
<date>2010-04-01T00:00:00</date>
<price>4.6 Cr</price>
<propertytitle>2BHK Apartment in BORIVALI - WEST for Outright</propertytitle>
</mob_searchpropertiesbybudget_Result>
<mob_searchpropertiesbybudget_Result z:Id="i2" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
<BrokerEmail />
<BrokerMobile>9594111465</BrokerMobile>
<BrokerName>Rohan Gill</BrokerName>
<BuildingAddress>INDIRA APARTMENTS</BuildingAddress>
<Buildingname>INDIRA APARTMENTS</Buildingname>
<ClientEmail />
<ClientMobile />
<ClientName>S P Thakur [98334 46831]</ClientName>
<PropertyId>2</PropertyId>
<area>2986</area>
<date>2010-04-01T00:00:00</date>
<price>7.76 Cr</price>
<propertytitle>3BHK Apartment in ANDHERI - EAST for Lease/Outright</propertytitle>
</mob_searchpropertiesbybudget_Result>
</ArrayOfmob_searchpropertiesbybudget_Result>
Without Data
<ArrayOfmob_searchpropertiesbybudget_Result xmlns="http://schemas.datacontract.org/2004/07/RealtyRadarMobileService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" />
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|