因为项目的需要,可能会经常性的需要调用接口,或者写一些接口。现在提供一些简单的例子给大家参考

写接口:

  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
[System.Web.Script.Services.ScriptService]
public class WebService_test : System.Web.Services.WebService
{ [WebMethod(Description="求和")]
public double Add(double a,double b)
{
return (a + b);
} [WebMethod(Description = "类")]
public string getjsno()
{
string jsno = string.Empty;
student st = new student();
st.Name="张三";
st.Sex="男"; JavaScriptSerializer jss = new JavaScriptSerializer();
jsno = jss.Serialize(st); return jsno;
} } public class student
{
private string name;
private string sex; public string Name
{
get { return name; }
set { name = value; }
} public string Sex
{
get { return sex; }
set { sex = value; }
}
}

调用接口:

  WebS.WebService_testSoapClient web=new WebS.WebService_testSoapClient();
double b = web.Add(,);
textbox.Text = b.ToString();
web.HelloWorld(); WebS.getjsnoRequest aaa=new WebS.getjsnoRequest();
aaa.ToString(); string cc=web.getjsno();
JavaScriptSerializer jss = new JavaScriptSerializer();

代码已经贴出来,调用哪里怎么样添加webservice接口,可以手动也可以代码去写,可以百度,这些很多例子。

.NET 的webservice例子的更多相关文章

  1. Spring Boot SOAP Webservice例子

    前言 本文将学习如何利用Spring boot快速创建SOAP webservice服务: 虽然目前REST和微服务越来越流行,但是SOAP在某些情况下,仍然有它的用武之地: 在本篇 spring b ...

  2. 极致精简的webservice例子

    看了网上好多关于webservice的例子,基本上对初学者来说都是模棱两可云里雾里,现在,我将网上关于webservice的讲解提炼出来,通过一个最简单使用并且方便的例子,告诉大家什么是webserv ...

  3. 使用CXF做简单的WebService例子

    使用Maven搭建项目测试简单的CXF实例 Server: pom.xml: <!-- begin CXF Server --> <dependency> <groupI ...

  4. ajax跨域调用webservice例子

    [WebMethod(Description = "这是一个描述")] public void GetTIM() { try { SqlDataAdapter da = new S ...

  5. 极致精简的webservice集成例子

    极致精简的webservice例子   看了网上好多关于webservice的例子,基本上对初学者来说都是模棱两可云里雾里,现在,我将网上关于webservice的讲解提炼出来,通过一个最简单使用并且 ...

  6. Java WebService 开发简单实例

    Web Service 是一种新的web应用程序分支,他们是自包含.自描述.模块化的应用,可以发布.定位.通过web调用.Web Service可以执行从简单的请求到复杂商务处理的任何功能.一旦部署以 ...

  7. Delphi动态调用Java的WebService 转

    Delphi动态调用Java的WebService —— 基于“Axis2发布WebService例子(HelloWorld)” uses ComObj; var WsObject: Variant; ...

  8. WebService与RESTful WebService

    Manual Instruction Document Web Service JAX-WS & JAX-RS Author: Liu Xiang Date: 2018/01/12 1. Su ...

  9. webservice和wcf和web.api简单介绍

    转自:无废话的wcf等等 在.net平台下,有大量的技术让你创建一个HTTP服务,像Web Service,WCF,现在又出了Web API.在.net平台下,你有很多的选择来构建一个HTTP Ser ...

随机推荐

  1. ALV的报表对用户定义格式的控制(ALV I_SAVE)

    很多ALV的报表都需要手动的进行设置格式以使数据看上去更有意义和条理,如果每次进来都重新操作一遍是很烦人的,所以SAP有提供了一个保存格式的功能,保存格式可以是 '缺省设置' 和 '特定用户' 两种 ...

  2. xmlBean学习二

    由上一遍的准备工作完成后,可以很简单的就进行对xml文件的操作, package com; import java.io.File; import java.io.IOException; impor ...

  3. Python3爬虫学习

    学了几天python3,发现目前学到的与爬虫还是关系不大,所以现在准备爬虫和语言同步学习. 2016.8.9晚 先从最简单的开始,爬取指定url的所有内容: #encoding:UTF-8 impor ...

  4. mysql的top n查询

    我们知道,在ms sql server中或access中,若要查询前10条记录,使用top 10即可,但在mysql中不支持这个写法,它用limit 10.  我们可以利用MySQL中SELECT支持 ...

  5. Cocos2D Study - Preparation & Installation

    ---------------------------------------------------------------------------------------------------- ...

  6. Codeforces Gym 100342D Problem D. Dinner Problem Dp+高精度

    Problem D. Dinner ProblemTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1003 ...

  7. 杭电 2034 人见人爱A-B

    http://acm.hdu.edu.cn/showproblem.php?pid=2034 人见人爱A-B Time Limit: 2000/1000 MS (Java/Others)    Mem ...

  8. [Javascript] Functor law

    Functor laws: 1. Identity: map(id) == id 2. Composition: compose(map(f), map(g)) == map(compose(f,g) ...

  9. Ejection chain 与交错路

    相关文献: Rego, C. (1998). "A Subpath Ejection Method for the Vehicle Routing Problem." Manage ...

  10. Apache 学习笔记(心得)

    http://blog.csdn.net/btbtd/article/details/288027#2 # 分类:# 01.常规设置# 02.虚拟主机# 03.<Directory> + ...