js调用webservice在微软的网站上有这样一个htc!
调用服务器端的函数请搜索以前的帖子,不只一次的有人在这里问过了!
调用服务器端的函数请搜索以前的帖子,不只一次的有人在这里问过了!
解决方案 »
- 支付宝快捷登录接口和标准双接口的区别和使用
- 庖丁解牛 第一技术讨论群29071846 欢迎大家光临
- 如何对2个文本文件的比较?
- 如果在ASP.net中设置表所有者
- 用asp.net操作word,始终有winword.exe进程杀不掉。ZHANG9652(剑神独孤求败)大侠请进,关于编写组件控制word的思路。
- 还是那个并发问题,第三次发帖了,难道没有人能解决吗??呜。。呜。。。伤心死了!!
- treeview中的节点超过3000个,打开的速度便奇慢无法比!
- 求助一个asp用XMLHTTP往asp.net页面请求获取数据的技术问题
- <img id="imgTP" runat="server" name="imgTP" src='<%=structInfo.strImg%>'>
- 关于页面间通讯问题!!
- 100分 如何调用网络打印机打印本地c:\test.txt 文件(网上等)
- 求助ASP.net登陆问题
XmlServerHttp.Open("Post","WebserviceURL","User,Name","Pswd");
XmlServerHttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
XmlServerHttp.Send("Msg");
<script>
function Call()
{
var objhttp=new ActiveXObject("Microsoft.XMLHTTP")
var xmldoc=new ActiveXObject("Microsoft.XMLDOM")
var strWebserviceURL="http://localhost/WebService1/Service1.asmx/Password" ;
var strRequest="s=dd" ;
objhttp.open ("post",strWebserviceURL,false);
objhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") ;
objhttp.send(strRequest)
//装载
if (xmldoc.load(objhttp.responseXML)) //成功
{
var rootNode =xmldoc.documentElement
alert(rootNode.firstChild.xml);
}
}
</script>
<html>
<body>
<input type=button onclick=Call() value="ok">
</body>
</html>
服务器端:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;namespace WebService1
{
/// <summary>
/// Service1 的摘要说明。
/// </summary>
//[WebService(Namespace="http://localhost/webserver/")]
public class Service1 : System.Web.Services.WebService
{
public Service1()
{
//CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的
InitializeComponent();
} #region 组件设计器生成的代码
//Web 服务设计器所必需的
private IContainer components = null;
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion // WEB 服务示例
// HelloWorld() 示例服务返回字符串 Hello World
// 若要生成,请取消注释下列行,然后保存并生成项目
// 若要测试此 Web 服务,请按 F5 键 [WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public string Password(string s)
{
byte []ss;
ss=System.Text.Encoding .UTF8 .GetBytes(s) ;
string sss=null;
foreach (byte e in ss)
{
sss+=e.ToString ();
}
return sss; }
}
}