Ajax在调用含有SoapHeader的webservice方法
· [WebService(Namespace = "http://tempuri.org/")]
· [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
· public class WebService4JQuery : System.Web.Services.WebService
· {
·
· public TestHeader THeader;
·
· [WebMethod]
· [SoapHeader("THeader")]
· public string TestSoapHeader()
· {
·
· return "THeader Value: " + THeader.HeaderData;
· }
· }
·
· public class TestHeader : SoapHeader
· {
· public string HeaderData { get; set; }
· }
#JQuery code in the webform page
<script type="text/javascript">
function CallWebMethodWithHeader() {
var soapXML =
"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" +
" <soap:Header>" +
"<TestHeader xmlns='http://tempuri.org/'>" +
"<HeaderData>111111111111</HeaderData>" +
"</TestHeader>" +
"</soap:Header>" +
"<soap:Body>" +
"<TestSoapHeader xmlns='http://tempuri.org/' />" +
"</soap:Body>" +
"</soap:Envelope>";
$.ajax({
url: "WebService4JQuery.asmx?op=TestSoapHeader",
type: "POST",
dataType: "xml",
contentType:"text/xml; charset=utf-8",
data: soapXML,
beforeSend: function (xhr) {
xhr.setRequestHeader('SOAPAction', 'http://tempuri.org/TestSoapHeader');
},
success: function (data) {
alert("webmethod call success");
},
error: function (err) {
alert("webmethod call failed");
}
});
}
</script>
Ajax在调用含有SoapHeader的webservice方法的更多相关文章
- .net 在不同情况下调用带soapheader的webservice的方式
国庆长假到了,本想出去玩玩,无奈自己屌丝一枚,啥都没有,只能自己宅在家里思考思考人生.不过人生还是过于复杂,一时间也想不出个所以然,只能是整理一下在工作中遇到的一些小问题,首先是关于带soaphead ...
- C#/PHP调用有SoapHeader的WebService
日前调用第三方WebService接口时遇到了SoapHeader验证的问题,记录一下解决方法. 接口需要的格式: <soapenv:Header> <ReqSOAPHeader x ...
- .net 客户端调用java或.net webservice进行soapheader验证
.net 客户端调用java或.net webservice进行soapheader验证 最近项目中有业务需要跨平台调用web服务,客户端和服务器之间采用非对称加密来保证数据的安全性,webservi ...
- 跨域Ajax请求WebService方法
一.允许跨域Ajax请求,更改如下配置: 在要调用的WebService上面添加特性标签: 二.以如下返回用户信息的WebService方法为例 三.在另一个网站上通过Ajax访问webService ...
- ajax aspx调用webservice,返回json
1,创建一个asp.net网站 2.创建一个student类 using System; using System.Collections.Generic; using System.Linq; us ...
- winform客户端程序第一次调用webservice方法很慢的解决方法
.net2.0的winform客户端最常用的与服务端通信方式是通过webservice,最近在用dottrace对客户端做性能测试的时候发现,客户端程序启动以后,第一次调用某一个webservice的 ...
- 利用JQuery的$.ajax()可以很方便的调用asp.net的后台方法
利用JQuery的$.ajax()可以很方便的调用asp.net的后台方法. 先来个简单的实例热热身吧. 1.无参数的方法调用 asp.net code: view plaincopy to clip ...
- Java调用.Net WebService参数为空解决办法 (远程)调试webservice方法 转
Java调用.Net WebService参数为空解决办法 (远程)调试webservice方法 同事遇到一个很囧的问题,java调,netwebservice的时候,调用无参数方法成功,调用有参 ...
- jQuery AJAX实现调用页面后台方法
1.新建demo.aspx页面.2.首先在该页面的后台文件demos.aspx.cs中添加引用. using System.Web.Services; 3.无参数的方法调用. 大家注意了,这个版本不能 ...
随机推荐
- hping3
[root@zxserver104 ~]# hping3 -c -d -S -w -p --flood --rand-source 115.236.6x.19x 1. hping3 = 应用程序二进制 ...
- hdu 4856 Tunnels (记忆化搜索)
Tunnels Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...
- SSL certificate problem unable to get local issuer certificate解决办法
SSL certificate problem unable to get local issuer certificate 解决办法: 下载:ca-bundle.crt 将它放在自己的wamp或者x ...
- eclipse在Ubuntu 13.04下的安装过程及问题小记
一.eclipse安装过程 首先确保在安装eclipse之前已经安装好Java虚拟机 1. eclipse官网下载压缩包 下载地址:http://www.eclipse.org/downloads/? ...
- zabbix_server 已死,但是 subsys 被锁
一开始 grant all privileges on zabbix.* to zabbix@localhost identified by 'password'; 将localhost改为ip后恢 ...
- openfire+asmack搭建的安卓即时通讯(六) 15.4.16
啊啊啊啊啊啊啊啊,这东西越做越觉得是个深坑啊! 1.SharedPreferences.Editor的密码保存和自动登录: 首先还是从主界面开始,因为要提升一下用户体验自然要加入保存密码和自动登录的功 ...
- Debian下安装deb格式安装包
dpkg -i 软件包名称 就好啦 下面是相应链接: http://blog.csdn.net/lhf_tiger/article/details/7493400
- POJ 3398 Perfect Service --最小支配集
题目链接:http://poj.org/problem?id=3398 这题可以用两种上述讲的两种算法解:http://www.cnblogs.com/whatbeg/p/3776612.html 第 ...
- linux下批量替换文件内容
1.网络上现成的资料 格式: sed -i "s/查找字段/替换字段/g" `grep 查找字段 -rl 路径` linux sed 批量替换多个文件中的字符串: (此命令很强大) ...
- Python 栅栏凯撒
def fence_Crypto(msg,priority="row"): ''' usage: fence_Crypto(msg[, priority])->msg to ...