2012-11-30 53 views

回答

0

我使用android系統中得到asp.net web服務的SOAP數據belove代碼試試這個

public static String SOAP_NAMESPACE = "http://myweb.com/"; 
public static String SOAP_METHOD_GetQuestionAnswer = "GetQuestionAnswer"; 

// GetQuestionAnswer Method 
public static String GetQuestionAnswer(String GameIDValue, String QuestionIDValue) { 
    String responce = null; 

    SoapObject request = new SoapObject(SOAP_NAMESPACE, SOAP_METHOD_GetQuestionAnswer); 

    PropertyInfo GameID = new PropertyInfo(); 
    PropertyInfo QuestionID = new PropertyInfo(); 

    GameID.setName("gameid"); 
    GameID.setValue(GameIDValue); 

    QuestionID.setName("queid"); 
    QuestionID.setValue(QuestionIDValue); 

    request.addProperty(GameID); 
    request.addProperty(QuestionID); 

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
    envelope.dotNet = true; 
    envelope.setOutputSoapObject(request); 
    HttpTransportSE aht = new HttpTransportSE(SOAP_URL); 
    try { 
     aht.call(SOAP_ACTION_GetQuestionAnswer, envelope); 
     SoapPrimitive LoginResult; 
     LoginResult = (SoapPrimitive)envelope.getResponse(); 
     System.out.println("=================GetQuestion Results: "+LoginResult); 
     System.out.println(LoginResult.toString()); 
     responce = LoginResult.toString(); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (XmlPullParserException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 

    return responce; 
} 
+0

我想從Android到Web服務 –

+0

其Web服務所使用的數據傳遞,充分休息或肥皂? – Hemant

+0

肥皂web服務 –

0

在Android中,您可以創建一個JSON objectPOSTasp web service,最終將數據發送到你的remote sql database

JSONObject obj = new JSONObject(); 
obj.put("val1",val1); 
obj.put("val2",val2); 
obj.put("val3",val3); 
+0

確定...感謝名單我會嘗試 –

+0

@shivanipatel嘿親愛的我檢查我的答案,這將有助於您的問題.. –

+0

@shivanipatel use List nameValuePairs = new ArrayList ; –

0

@shivanipatel

首先從服務器端ü想擁有或建立任何Web服務從Android和響應這一要求收到您的請求.. ///

之後,你想使用
使用NameValuePair來做Post數據。

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>; 
nameValuePairs.add(new BasicNameValuePair("name", Name)); 
nameValuePairs.add(new BasicNameValuePair("number", Number)); 

httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 

HttpResponse response = httpclient.execute(httppost); 

這將幫助ü親愛

--Jatin帕特爾

+0

@shivanipatel歡迎在未來如果你有問題,然後自由地問我好嗎.. –

+0

你確定................ –

相關問題