int sitesrno = Integer.parseInt(alPhotoMainDetail.get(i).get("SITE_SRNO"));
int eqsrno = Integer.parseInt(alPhotoMainDetail.get(i).get("EQPSRNO"));
char phototype = alPhotoMainDetail.get(i).get("PHOTOTYPE").charAt(0);
char catsrno = alPhotoMainDetail.get(i).get("CATSRNO").charAt(0);
int usersrno = Integer.parseInt(alPhotoMainDetail.get(i).get("USERSRNO"));
String dtime = alPhotoMainDetail.get(i).get("ENTRYDATE");
String othername = "ss";
isEPHead = parsing.insertEPhotoHead(max, sitesrno, eqsrno, phototype, catsrno, usersrno, dtime, othername);
public boolean insertEPhotoHead(int RefSrNo, int SiteSrNo, int EqpSrNo, char pp, char CatSrNo, int UserSrNo, String EntryDate, String OtherName) {
try {
SoapObject request = new SoapObject(NAMESPACE, SOAP_METHOD_EPHEAD);
request.addProperty("RefSrNo", RefSrNo);
request.addProperty("SiteSrNo", SiteSrNo);
request.addProperty("EqpSrNo", EqpSrNo);
request.addProperty("PhotoType", pp);
request.addProperty("CatSrNo", CatSrNo);
request.addProperty("UserSrNo", UserSrNo);
request.addProperty("EntryDate", EntryDate);
request.addProperty("OtherName", OtherName);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
MarshalDouble md = new MarshalDouble();
md.register(envelope);
AndroidHttpTransport aht = new AndroidHttpTransport(URL);
aht.call(SOAP_ACTION_EPHEAD, envelope);
SoapObject response = (SoapObject) envelope.getResponse();
boolean res = Boolean.parseBoolean(response.toString());
MarshalDouble.java
public class MarshalDouble implements Marshal {
public Object readInstance(XmlPullParser parser, String namespace, String name,
PropertyInfo expected) throws IOException, XmlPullParserException {
return (parser.nextText()).charAt(0);
}
public void register(SoapSerializationEnvelope cm) {
cm.addMapping(cm.xsd, "char", char.class, this);
}
public void writeInstance(XmlSerializer writer, Object obj) throws IOException {
writer.text(obj.toString());
}
}
日志猫:
04-30 17:17:37.080: W/System.err(6562): java.lang.RuntimeException: Cannot serialize: E
04-30 17:17:37.080: W/System.err(6562): at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:629)
04-30 17:17:37.080: W/System.err(6562): at org.ksoap2.serialization.SoapSerializationEnvelope.writeProperty(SoapSerializationEnvelope.java:613)
04-30 17:17:37.080: W/System.err(6562): at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:582)
04-30 17:17:37.080: W/System.err(6562): at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:566)
04-30 17:17:37.080: W/System.err(6562): at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:623)
04-30 17:17:37.080: W/System.err(6562): at org.ksoap2.serialization.SoapSerializationEnvelope.writeBody(SoapSerializationEnvelope.java:547)
04-30 17:17:37.080: W/System.err(6562): at org.ksoap2.SoapEnvelope.write(SoapEnvelope.java:192)
04-30 17:17:37.080: W/System.err(6562): at org.ksoap2.transport.Transport.createRequestData(Transport.java:74)
04-30 17:17:37.080: W/System.err(6562): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:58)
04-30 17:17:37.080: W/System.err(6562): at com.example.CommanDatabase.Parsing.insertEPhotoHead(Parsing.java:196)
04-30 17:17:37.080: W/System.err(6562): at com.example.orecs.LoginAct$LoginAsyncTask.doInBackground(LoginAct.java:407)
04-30 17:17:37.080: W/System.err(6562): at com.example.orecs.LoginAct$LoginAsyncTask.doInBackground(LoginAct.java:1)
04-30 17:17:37.090: W/System.err(6562): at android.os.AsyncTask$2.call(AsyncTask.java:252)
04-30 17:17:37.090: W/System.err(6562): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
04-30 17:17:37.090: W/System.err(6562): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
04-30 17:17:37.090: W/System.err(6562): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081)
04-30 17:17:37.090: W/System.err(6562): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:574)
04-30 17:17:37.090: W/System.err(6562): at java.lang.Thread.run(Thread.java:1020)
注意:我正在使用此网络服务并传递所有值。但 'phototype' char 数据类型有问题。它显示错误。我不知道是什么原因。请帮助摆脱这种情况。