我是 , 的Android
新手KSOAP
。我主要做.NET
。我正在写一个试图Android App
从..NET Service
IIS Server
导致错误的行是:
androidHttpTransport.call(SOAP_ACTION, envelope);
它失败了,但有以下例外:
org.xmlpull.v1.XmlPullParserException:预期:START_TAG { http://schemas.xmlsoap.org/soap/envelope/ }信封(位置:START_TAG @2:7 in java.io.InputStreamReader@41527620)
从浏览器调用时,Web Service
我正在调用的似乎返回XML
得很好。
我需要做些什么IIS Server
才能成功调用服务KSOAP2
吗?
任何帮助将不胜感激。
安卓代码:
package com.example.vdu;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.HttpTransportSE;
import android.widget.TextView;
public class DirectorySyncActivity extends Activity {
private static final String NAMESPACE = "http://www.mycompany.com/";
private static final String URL = "http://www.mycompany.com/vdus/service1.asmx/Directory";
private static final String METHOD_NAME = "Directory";
private static final String SOAP_ACTION = "http://www.mycompany.com/vdus/Directory";
Object response;
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getdirdata();
}
private void getdirdata() {
new Thread() {
@Override
public void run() {
try
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope =new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
java.lang.String directorystring = (String)envelope.getResponse().toString();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.directory_sync, menu);
return true;
}
}