无法通过 Android ksoap2 从 Web 服务接收数据
cant recive data from WebService via Android ksoap2
我正在尝试将字符串发送到网络服务并从中获取重播。
我使用 android studio 在 java 上为 android
编程
和 visual-studio 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;
}
}
我只得到 Helo: 而没有我发送的字符串
而不是 Helo: 新用户
比
尝试改变这个:
//Set Name
info.setName("HELO");
对此:
//Set Name
info.setName("Name");
我正在尝试将字符串发送到网络服务并从中获取重播。
我使用 android studio 在 java 上为 android
编程和 visual-studio 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;
}
}
我只得到 Helo: 而没有我发送的字符串 而不是 Helo: 新用户
比
尝试改变这个:
//Set Name
info.setName("HELO");
对此:
//Set Name
info.setName("Name");