ajax如何调用带有SoapHeader的 web service?能否告知如何做?Ajax访问Xml Web Service的我会做,但是访问 带有SoapHeader的 web service还不明白怎么做?
解决方案 »
- 关于乱码的编码问题,急~~~~~
- asp.net 怎样屏蔽迅雷快车等下载软件
- 【加急!!】json转成数组,求高手指教,在线等...
- |zyciis| 今天看了一个ShopeEx的电子商城的测试后台,好强大啊。请问一下大家,他那个列表如何来做,谢谢
- ajax跨域访问rss
- 在asp.net1.1的机器上安装asp.net2.0后无法将站点设回asp.net1.1环境的问题
- 求网址源码
- 为什么发送邮件的程序收不到发送的邮件
- 大家帮忙看一下,为什么用Session保存不了值?
- image 对象如何转换成 HttpPostedFile 呢
- 如何获得文件下载对话框的返回值
- 怎样获取后台InnerHtml定义的ID呀
[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; }
}<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>
代码来自:
how to add soap header from jquery ajax call?
http://forums.asp.net/t/1794228.aspx/