2016-01-20 84 views
2

我試圖將字符串發送到webservice並獲取重播。無法通過Android ksoap2從WebService收集數據

我使用Android工作室編程基於Java的Android

和視覺工作室2010編程的C#web服務。

我已經在Android

private static final String SOAP_ACTION = "http://tempuri.org/HELO"; 

    private static final String OPERATION_NAME = "HELO";// your webservice web method name 

    private static final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/"; 

    private static final String SOAP_ADDRESS = "http://10.0.0.2/WS_TEST/Service1.asmx"; 



      SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME); 
      PropertyInfo info= new PropertyInfo(); 
      info = new PropertyInfo(); 
      //Set Name 
      info.setName("HELO"); 
      //Set Value 
      info.setValue("New User"); 
      //Set dataType 
      info.setType(String.class); 
      //Add the property to request object 
      request.addProperty(info); 

      SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
      envelope.dotNet = true; 

      envelope.setOutputSoapObject(request); 
      HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS); 
      try { 
       httpTransport.call(SOAP_ACTION, envelope); 
       Object response = envelope.getResponse(); 
       tvData1.setText(response.toString()); 
      } catch (Exception exception) { 
       tvData1.setText(exception.toString()); 
      } 

and this my C# WebService 

    [WebService(Namespace = "http://tempuri.org/")] 
     [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
     [System.ComponentModel.ToolboxItem(false)] 
     // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
     // [System.Web.Script.Services.ScriptService] 
     public class Service1 : System.Web.Services.WebService 
     { 

      [WebMethod] 
      public string HELO(string Name) 
      { 
       return "Hello : " + Name; 
      } 

     } 

這個代碼,我只拿到了直升機:沒有,我送 代替直升機字符串:新用戶

thans

+0

我有同樣的問題......也許有人可以幫忙嗎? – Gold

+0

請問?任何人 ? –

回答

1

嘗試改變這一點:

//Set Name 
      info.setName("HELO"); 

這樣:

//Set Name 
      info.setName("Name");