2012-11-30 18 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

你确定................ –

相关问题