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

推荐订阅源

IT之家
IT之家
Y
Y Combinator Blog
月光博客
月光博客
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
有赞技术团队
有赞技术团队
博客园 - 司徒正美
V
Visual Studio Blog
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
A
About on SuperTechFans
The Cloudflare Blog

博客园 - Jwin

【转】最近ASP.NET WAP开发的一些情况 showModelessDialog()使用详解 showModalDialog和showModelessDialog的使用【转】 招聘兼职项目开发,寻找长期合作伙伴 转载:动态调用WebService(C#) 数据库优化不能不知道的工具:Database Engine Tuning Advisor【原创】 如何把文件上传到另外一台服务器【转】 memcached 介绍 asp.net实现显示在线会员 项目兼职:SQL Server数据库优化(价格面议) 做网站的人必须遵守的N大定律 ajax 脚本错误 'sys'未定义 (高价)项目兼职:开发qq机器人 关于博客园程序主页模板改进的若干建议 修改UrlRewrite以对域名进行重写,即实现二级或多级域名 【转】 对于URL重写,支持无后缀url请求【转】 转:分布式缓存系统Memcached简介与实践 ASP.NET 2.0的页面缓存功能介绍 [转] Awstats 安装使用说明(转)
WebService传多个参数和返回多个参数的方法【转】
Jwin · 2008-11-19 · via 博客园 - Jwin

原文:http://www.cnblogs.com/tuyile006/archive/2007/06/14/783384.html

WebService方面:

在webService项目中新建两个类访问性都为public
request:用来存放请求参数;

public class request
{
    
public request()
    {
    }
    
public string name;
    
public string sex;
    
public int age;
    
public string enable;
}


response:用来存放应答参数;

public class response
{
 
public response()
 {
  
 }
    
public string name2;
    
public string sex2;
    
public int age2;
    
public bool marry;
}


在webService中使用方法:

[WebMethod(Description = "real test")]
    
public response change(request re)
    {
        response resp 
= new response();
        resp.name2 
= re.name + "2";
        resp.sex2 
= re.sex + "2";
        resp.age2 
= re.age + 2;
        resp.marry 
= false;
        
return resp;
    }

这个方法测试接收多个参数,并改变其值后返回多个参数


在Web项目中调用WebService:

添加webService的引用,假设引用名为localhost,使用该webService的方法如下:
客户端不用再另加request和response两个类。

        localhost.request re = new localhost.request();
        re.name 
= "aa";
        re.sex 
= "man";
        re.age 
= 12;
        re.enable 
= "true";
        localhost.Service ser 
= new localhost.Service();
        localhost.response res 
= ser.change(re);
        Response.Write(res.name2
+"<br>"+res.sex2+"<br>"+res.age2.ToString()+"<br>"+res.marry.ToString());


关于调用webservice时出现401错误:Access Denied 
解决办法:将webservice的访问权限加上“允许匿名访问”,在webService属性的“目录安全性”选项卡中。