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

推荐订阅源

T
Tailwind CSS Blog
博客园 - Franky
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Y
Y Combinator Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
L
LangChain Blog
博客园_首页
Recent Announcements
Recent Announcements
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Hackread – Cybersecurity News, Data Breaches, AI and More
爱范儿
爱范儿
博客园 - 叶小钗
博客园 - 【当耐特】
The Cloudflare Blog
J
Java Code Geeks
G
Google Developers Blog
云风的 BLOG
云风的 BLOG
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans

博客园 - 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属性的“目录安全性”选项卡中。