加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

webservice

发布时间:2020-12-17 02:48:06 所属栏目:安全 来源:网络整理
导读:using System; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class Service : System.Web

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
??? public Service () {

??????? //如果使用设计的组件,请取消注释以下行
??????? //InitializeComponent();
??? }

??? [WebMethod]
??? public string HelloWorld() {
??????? return "Hello World";
??? }
??? [WebMethod]
??? public string myTest()
??? {

????????
??????? return "myTestReturn";

??? }
???
}

?

<?xml version="1.0" encoding="utf-8" ?>
? <string xmlns="http://tempuri.org/">myTestReturn</string>

?

SOAP 1.2 请求和响应
POST /WebSite2/Service.asmx HTTP/1.1
Host: localhost
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
? <soap12:Body>
??? <myTest xmlns="http://tempuri.org/" />
? </soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
? <soap12:Body>
??? <myTestResponse xmlns="http://tempuri.org/">
????? <myTestResult>string</myTestResult>
??? </myTestResponse>
? </soap12:Body>
</soap12:Envelope>
?

?

?

调用:

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读