所以我有運行嘗試發送6個變量到Web服務(http://hydra.chorleywood.org/hydradevices/devicesmanagement.asmx)ksoap2-的Android connecitong問題
我使用ksoap2 - 安卓Android中的一個問題4.2 API 17
我計劃每崩潰我按下了它所關聯的按鈕。我已經瀏覽了很多教程,並且完成了它們的工作,但對於我來說,無論是在eclipse中運行還是導出並在手機上運行它都無濟於事。
這裏是代碼
private static final String NAMESPACE = "http://hydra.chorleywood.org";
private static final String URL="http://hydra.chorleywood.org/hydradevices/devicesmanagement.asmx";
private static final String METHOD1_SOAP_ACTION_URL = "http://hydra.chorleywood.org/addNewDevice";
private static final String METHOD_NAME1 = "addNewDevice";
final Button status_button = (Button) findViewById(R.id.device_status);
status_button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
// setting my variables
String EUI64 = "EHF7980HY3G793HG393GF737GH80G7";
String HashCode = "MB2GPD";
int DeviceTypeID = 528391;
String subType = "Weighing Scales";
String Manufacturer = "Samsung";
String SerialNumber = "8476403967";
// setting connectionas
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
envelope.dotNet = true;
// setting informaiton to be sent
request.addProperty("EUI64", EUI64);
request.addProperty("HashCode", HashCode);
request.addProperty("DeviceTypeID", DeviceTypeID);
request.addProperty("subType", subType);
request.addProperty("Manufacturer", Manufacturer);
request.addProperty("SerialNumber", SerialNumber);
// setting request to be sent out
envelope.setOutputSoapObject(request);
try
{
androidHttpTransport.call(METHOD1_SOAP_ACTION_URL, envelope);
//java.lang.String receivedString = (String)envelope.getResponse();
//java.lang.Boolean receivedBoolean = (Boolean)envelope.getResponse();
Object result = envelope.getResponse();
/**if(receivedBoolean = true) {
Context context = getApplicationContext();
CharSequence text = "testing toast";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}**/
}
catch(Exception e)
{
}
}
我已經設置了權限在清單 的相關部分,我不能確定到底什麼是錯的,沒有人知道?
我嘗試過不同的API,但仍然無法正常工作。 我真的很感謝在這個話題上的任何幫助,我已經放了一個星期到目前爲止,我只是在圈子裏跑。
我從字面上複製粘貼其他人民的網絡服務(我認爲是一個活躍的服務器),並試圖運行他們的確切代碼,似乎也沒有工作。也許這將幫助你弄清楚我遇到的問題。
非常感謝,
查理