0

AndroidアプリケーションからC#Webサービスを利用したい..私のプロジェクトでは、kSOAP 2ライブラリを使用して、データを取り戻すリクエストでSOAPを使用していますが、自分で「呼び出し」を行っているとき...... asmx 、C# バックエンド、このコード

     SoapObject getWeather(String customerNumber) throws Exception {
    PropertyInfo property = new PropertyInfo();
    property.setName("LicenseId");
    property.setValue("8BEBFB9F-D9C9-4880-9225-AB50976F2975");
    property.setType(String.class);

    SoapObject request = new SoapObject("http://mobilesuite365.com",
            "GetCustomers");
    request.addProperty(property);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);
    // It seems that it is a .NET Web service because it doesn't work
    // without next line


    HttpTransportSE transport = new HttpTransportSE(
            "http://www.mobilesuite365.net/app2/getdata.asmx");
    transport.debug = true;
    transport.call("http://mobilesuite365.com/GetCustomers", envelope);



    return (SoapObject) envelope.getResponse();

このエラー "XmlPullParserException: Unexpected token (position:TEXT") が表示されます。応答は JSON のようになりますが、ksoap は xml 形式を処理できるためです。

応答を取得して応答から情報を処理し、アプリで使用する方法は?

手伝ってくれてありがとう

4

1 に答える 1

0

SoapPrimitiveaの代わりに aを使用して、型SoapObjectに変換してみてくださいString

String response = "";
SoapPrimitive result = (SoapPrimitive) envelope.getResponse();
if (result != null)
    response = result.toString();

return response;

その後、受け取っGsonたを解析するようなものを使用する必要がありJSONます。

于 2014-11-04T09:59:15.553 に答える