惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
J
Java Code Geeks
C
Check Point Blog
Last Week in AI
Last Week in AI
Microsoft Azure Blog
Microsoft Azure Blog
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
L
LangChain Blog
有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 司徒正美
IT之家
IT之家
Martin Fowler
Martin Fowler
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
U
Unit 42
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ

博客园 - stonespawn

Vue 组件库2 Vue 的组件库 算法小题目 VS2019 自动代码补全功能 GIT 删除操作 vue-router 注意事项 Vue中axios访问 后端跨域问题 Vue2.0 搭配 axios Vue 脚手架搭建 grunt使用入门 Git相关操作及记录 关于JS 树形结构 导出EXCEL【Web方式HTML通过拼接html中table】 链接点击跳动问题 WatiN——Web自动化测试(三)【弹出窗口处理】 WatiN——Web自动化测试(二) WatiN——Web自动化测试(一) 网页调用服务程序 - stonespawn - 博客园 小问题 小技巧 :创建虚拟目录并将IIS里面.net配置版本设为2.0 - stonespawn
Ajax在调用含有SoapHeader的webservice方法
stonespawn · 2014-01-16 · via 博客园 - stonespawn
·         [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>