【发布时间】:2017-07-21 18:06:31
【问题描述】:
我的 webservicecall.java 文件包含调用服务器的代码
public class WebserviceCall {
/**
* Variable Decleration................
*
*/
String namespace = "http://bkagartala.technotripura.com/";
private String url = "http://bkagartala.technotripura.com/asha/WebService.asmx";
String SOAP_ACTION;
SoapObject request = null, objMessages = null;
SoapSerializationEnvelope envelope;
HttpTransportSE androidHttpTransport;
WebserviceCall() {
}
/**
* Set Envelope
*/
protected void SetEnvelope() {
try {
// Creating SOAP envelope
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
//You can comment that line if your web service is not .NET one.
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
androidHttpTransport = new HttpTransportSE(url);
androidHttpTransport.debug = true;
} catch (Exception e) {
System.out.println("Soap Exception---->>>" + e.toString());
}
}
// MethodName variable is define for which webservice function will call
public String getchange_liveserver(String MethodName, String f_name)
{
try {
SOAP_ACTION = "http://tempuri.org/"+MethodName;
//Adding values to request object
request = new SoapObject(namespace, MethodName);
//Adding Double value to request object
PropertyInfo weightProp =new PropertyInfo();
weightProp.setName("f_name");
weightProp.setValue(f_name);
weightProp.setType(String.class);
request.addProperty(weightProp);
//Adding String value to request object
SetEnvelope();
try {
//SOAP calling webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
//Got Webservice response
String result = envelope.getResponse().toString();
return result;
} catch (Exception e) {
// TODO: handle exception
return e.toString();
}
} catch (Exception e) {
// TODO: handle exception
return e.toString();
}
}
/************************************/
}
在 asynctask 中将该 Web 服务类调用到另一个活动
aResponse = com.getchange_liveserver("soumya", "one");
但主要问题应用程序没有将该值发送到服务器......
网络服务代码
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
<WebMethod()> _
Public Function soumya(ByVal f_name As String) As String
Dim a As String = f_name
If a = "one" Then
a = "hello"
Return a
ElseIf a = "two" Then
a = "may"
Return a
Else
a = "do"
Return a
End If
End Function
End Class
【问题讨论】:
-
发布您遇到的错误或异常
-
我没有得到任何错误只是没有得到所需的输出。
-
它应该给我“你好”
-
问题是它正在向 Web 服务发送空值
标签: android web-services android-asynctask