我是这个Ksoap网络服务电话的新手。我知道如何从webservice调用中检索数据,但是如何发送Object的ArrayList。
我的网络服务如下:
<message name="InsertBrandOrder">
<part name="Token" type="xsd:string"/>
<part name="UserID" type="xsd:int"/>
<part name="StoreID" type="xsd:int"/>
<part name="BrandOrders" type="ns1:anyTypeArray"/>
</message>
<message name="InsertBrandOrderResponse">
<part name="ResponseInsertBrandOrder" type="tns:result"/>
</message>
此处BrandOrders是包含anyType的数组。
我有一个Product.java类
public class Product {
String name;
String position;
int brandId;
boolean is_order;
boolean is_merchandising;
boolean is_audit;
Product(String product_name,String brand_position,int brandid,boolean isorder,boolean ismerchandising, boolean isaudit)
{
name = product_name;
position=brand_position;
brandId=brandid;
is_order = isorder;
is_merchandising = ismerchandising;
is_audit = isaudit;
}
}
我的名为ViewYourPlanToday.java的Api调用类肯定部分代码如下所示:
SoapObject request = new SoapObject(RouteTrackerApp.NAMESPACE,
METHOD_NAME);
request.addProperty("Token", rep1);
request.addProperty("UserID",uid);
request.addProperty("StoreID", sid);
request.addProperty("BrandOrders",resultarray);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(
RouteTrackerApp.URL);
try
{
androidHttpTransport.call(RouteTrackerApp.SOAP_ACTION, envelope);
SoapObject responseInner = (SoapObject) envelope.bodyIn;
System.out.println("class:"+envelope.bodyIn.getClass());
...... }
但我收到的错误是:
01-07 12:28:17.680: W/System.err(7867): java.lang.RuntimeException: Cannot serialize: [com.m9.android.routetracker.ViewYourPlanToday$Product@40ce35d0]
01-07 12:28:17.710: W/System.err(7867): at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:664)
01-07 12:28:17.710: W/System.err(7867): at org.ksoap2.serialization.SoapSerializationEnvelope.writeProperty(SoapSerializationEnvelope.java:649)
01-07 12:28:17.730: W/System.err(7867): at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:595)
01-07 12:28:17.730: W/System.err(7867): at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:573)
01-07 12:28:17.730: W/System.err(7867): at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:658)
01-07 12:28:17.740: W/System.err(7867): at org.ksoap2.serialization.SoapSerializationEnvelope.writeBody(SoapSerializationEnvelope.java:555)
01-07 12:28:17.740: W/System.err(7867): at org.ksoap2.SoapEnvelope.write(SoapEnvelope.java:205)
01-07 12:28:17.770: W/System.err(7867): at org.ksoap2.transport.Transport.createRequestData(Transport.java:134)
01-07 12:28:17.770: W/System.err(7867): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:144)
01-07 12:28:17.780: W/System.err(7867): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:116)
01-07 12:28:17.780: W/System.err(7867): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:111)
任何人都可以帮我解决这个错误。
答案 0 :(得分:0)
为类产品实施java.io.Serializable
public class Product implements java.io.Serializable