0

以下のコードのように wcf webservice にアクセスしたい:

void farmCreate(String userName,
        String authToken) {
    String resultData = null;
    Hashtable<String, String> responseHashTable = new Hashtable<String, String>();
    try {
        FarmClass farm = new FarmClass();
        StringBuilder sb = null;
        SoapObject request = new SoapObject(Controller.NAMESPACE,  "MethodName");
        request.addProperty("aaaa", userName);
        request.addProperty("aaaa", authToken);
        request.addProperty("aaaa", farm);
        request.addProperty("aaaaa", "Add");

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);

          MarshalDate md = new MarshalDate();
            md.register(envelope);

            MarshalFloat md1 = new MarshalFloat();
            md1.register(envelope);

        HttpTransportSE androidHttpTransport = new HttpTransportSE(Controller.URL6767);
        androidHttpTransport.call(Controller.SOAP_ACTION + "method name", envelope);


        //new MarshalBase64().register(envelope);
        Object result = (Object) envelope.getResponse();

        resultData = result.toString();



    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
        System.out.println("error is occured :-" + e.getMessage());
    }


}

ただし、応答として、以下のように 1 つのエラーを生成します。

 06-20 12:50:03.673: W/System.err(596): java.lang.RuntimeException: Cannot serialize: []
06-20 12:50:03.673: W/System.err(596):  at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:679)
06-20 12:50:03.684: W/System.err(596):  at org.ksoap2.serialization.SoapSerializationEnvelope.writeProperty(SoapSerializationEnvelope.java:663)
06-20 12:50:03.684: W/System.err(596):  at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:632)
06-20 12:50:03.684: W/System.err(596):  at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:675)
06-20 12:50:03.684: W/System.err(596):  at org.ksoap2.serialization.SoapSerializationEnvelope.writeProperty(SoapSerializationEnvelope.java:663)
06-20 12:50:03.684: W/System.err(596):  at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:632)
06-20 12:50:03.684: W/System.err(596):  at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:616)
06-20 12:50:03.684: W/System.err(596):  at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:673)
06-20 12:50:03.684: W/System.err(596):  at org.ksoap2.serialization.SoapSerializationEnvelope.writeBody(SoapSerializationEnvelope.java:597)
06-20 12:50:03.684: W/System.err(596):  at org.ksoap2.SoapEnvelope.write(SoapEnvelope.java:192)
06-20 12:50:03.694: W/System.err(596):  at org.ksoap2.transport.Transport.createRequestData(Transport.java:101)
06-20 12:50:03.694: W/System.err(596):  at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:114)
06-20 12:50:03.694: W/System.err(596):  at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:90)
06-20 12:50:03.694: W/System.err(596):  at com.track.controller.SoapWebService.farmCreate(SoapWebService.java:113)
06-20 12:50:03.694: W/System.err(596):  at com.track.view.LiveStock.onCreate(LiveStock.java:82)
06-20 12:50:03.694: W/System.err(596):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-20 12:50:03.694: W/System.err(596):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
06-20 12:50:03.704: W/System.err(596):  at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
06-20 12:50:03.704: W/System.err(596):  at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
06-20 12:50:03.704: W/System.err(596):  at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)

だから、シリアライゼーションの概念について誰か考えているので、教えてください。前もって感謝します。

4

1 に答える 1

0

オブジェクトをシリアル化するには、Serializableを実装する必要があります。FarmClassのSerializableクラスを実装してみてください。

于 2012-06-20T07:45:00.837 に答える