解决方案 »
- 如何查找repeater控件中的文本框
- 各位大神,帮帮忙啊。。。如何实现两个页面之间的跳转
- 关于注销的问题
- 会员注册模块的问题
- fck在web.config里的配置!
- js高手请来指点 有关js给session赋值的问题
- 不错的ASP.Net入门Blog
- 请帮忙看一下关于datagrid的更新的问题?
- 从客户端(FreeTextBox1="<P align=right>grgrf...")中检测到有潜在危险的 Request.Form 值 怎么半?
- 关于查询的问题
- 求radiobuttonlist的用法: 例如说,点击读者就进入读者应用的界面,点击管理员进入管理员应用界面
- 想知道哪些登录用户在哪些页面上停留了多长时间,这样做可行吗?
.NET的 webservice 端代码: 用 本机的IIS 发布的 (浏览器访问 能正确 调用webservice )
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data.SqlClient;
using System.Data;//[WebService(Namespace = "http://tempuri.org/")]
//[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][WebService(Namespace = "http://192.168.1.102:8086/")]
[System.Web.Services.Protocols.SoapRpcService]public class Service : System.Web.Services.WebService
{
public Service () { //如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod(Description = "数据操作")] public string Hello(string strName)
{
return strName;
}
}
Android端代码:
package weather.android;import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;import weather.android.R.string;import android.R.bool;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;public class AndroidweatherActivity extends Activity {
/** Called when the activity is first created. */
private Button okButton;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
okButton = (Button) this.findViewById(R.id.button1);
okButton.setOnClickListener(new OnClickListener(){ public void onClick(View v) {
// TODO Auto-generated method stub
String cityname="sky";
Hello(cityname);
}
});
}
public static String Url = "http://192.168.1.102:8086/Service.asmx";
public static String NameSpace = "http://192.168.1.102:8086/";//这里就是基本那个空间名,实际用地时候看你的.NET部分
public static String MethodName ="";
public static String SoapAction = NameSpace + MethodName;
public static String Hello(String strName)
{
MethodName ="Hello";
SoapAction = NameSpace + MethodName;
try{
SoapObject request = new SoapObject(NameSpace, MethodName);
request.addProperty("strName",strName);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); //必须用VER11才能调用到.net的 ws
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE ht = new HttpTransportSE(Url);
ht.call(SoapAction, envelope);
if(envelope.getResponse()!=null)
{
System.out.println("detail1 "+envelope.getResponse() );
}
else
{
System.out.println("detail2 " );
}
}
catch (Exception e) { System.out.println("detail3 " + e);
}
return strName;
} }
需解决问题:
——————————————————————
整个Android 程序 运行后 总显示 结果 为 System.out.println("detail2 " ); 即 envelope.getResponse()得到的值为null 如何android端才能 正确 调用 webservice (向webservice 发送参数)求大牛门帮帮忙 多谢啦 !!
web调用 我也会 windows mobil 的 调用webservices 也做过 ,
都还算顺利
就这个 Android 的 折腾坏我了
一定要解决 还是要 谢谢 2 楼 的回复