1
您好我有一個問題相關到Android KSOAP,我第一次與KSOAP Android平臺KSOAP ANDROID實施
在這裏你可以看到請求和響應,也提到有, 這裏是我的代碼打到服務和獲取響應` 包com.ksoap.net;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class AndroidWebService extends Activity {
private final String NAMESPACE = "http://webservices.iyogi.net/";
private final String URL = "http://sdservices.iyogi.net /iyogi /webservicesnonrestv5/toolbarwebservices.asmx";
private final String SOAP_ACTION = "http://webservices.iyogi.net/GetSubscriptionByInputObject";
private final String METHOD_NAME = "GetSubscriptionByInputObject";
String request = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<soap:Envelope "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
+ "xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\">"
+ "<soap:Body>"
+ "<GetSubscriptionByInputObject xmlns=\"http://webservices.iyogi.net\">"
+ "<inpAccessCode>" + "<AccessCode>」2466276627755434」</AccessCode>"
+ "</inpAccessCode>" + "</GetSubscriptionByInputObject>"
+ "</soap:Body>" + "</soap:Envelope>";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
String weight = "3700";
String fromUnit = "Grams";
String toUnit = "Kilograms";
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(
URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject response = (SoapObject) envelope.getResponse();
int result = Integer.parseInt(response.getProperty(0).toString());
System.out.println("result is " + Integer.toString(result));
System.out.println("res is -->> "
+ response.getProperty(0).toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}`
請幫我打,並得到從這項服務中 任何幫助,高度讚賞
感謝您的寶貴回覆 我得到06-22 11:43:48.588:警告/ System.err(671):SoapFault - faultcode:'肥皂:服務器'faultstring:'服務器無法處理請求。 --->對象引用未設置爲對象的實例。' faultactor:「空」的細節:[email protected] 問題,我們該如何解決,你的答覆是高度appriciated – user1346836
Thnaks您寶貴的答覆 – user1346836
@Braj爵士 - 漂亮的笑話,引用沒有太問題回答 –