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

推荐订阅源

雷峰网
雷峰网
WordPress大学
WordPress大学
MyScale Blog
MyScale Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Blog of Author Tim Ferriss
U
Unit 42
罗磊的独立博客
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
aimingoo的专栏
aimingoo的专栏
Vercel News
Vercel News
N
Netflix TechBlog - Medium
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG
Hugging Face - Blog
Hugging Face - Blog
大猫的无限游戏
大猫的无限游戏
F
Fortinet All Blogs
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
博客园 - 【当耐特】
H
Help Net Security
The GitHub Blog
The GitHub Blog

博客园 - L.Zhang

.Net Remoting RMI框架 自己开发连接池 JDBC访问数据库 MyEclipse下开发Web Service 使用传统的XMLHttpRequest发出Ajax请求 XML CDATA XPath 数据库操作的sql脚本 直接选择排序 直接插入排序 气泡排序 Builder 生成器模式(创建型模式) Abstract Factory 抽象工厂模式(创建型模式) Factory Method 工厂方法模式(创建型模式) Singleton单件模式(创建型模式) 使用Profile Service 服务端如何使用Session 用Get方式访问
让服务端返回xml
L.Zhang · 2007-10-28 · via 博客园 - L.Zhang

//客户端代码

 <form id="form1" runat="server">
        
<asp:ScriptManager runat="server" ID="ScriptManager1" ScriptMode="Debug">
            
<Services>
                
<asp:ServiceReference Path="Services/ReturnXmlService.asmx" InlineScript="true" />
            
</Services>
        
</asp:ScriptManager>
        
        
<input type="button" value="GetXmlDocument" onclick="ReturnXmlService.GetXmlDocument(onSucceeded);" /><br /><br />
        
<input type="button" value="GetXmlElement" onclick="ReturnXmlService.GetXmlElement(onSucceeded);" /><br /><br />
        
<input type="button" value="GetEmployee" onclick="ReturnXmlService.GetEmployee(onSucceeded);" /><br /><br />
        
<input type="button" value="GetXmlString" onclick="ReturnXmlService.GetXmlString(onSucceeded);" /><br /><br />
        
<input type="button" value="GetSerializedString" onclick="ReturnXmlService.GetSerializedString(onSucceeded);" />
        
        
<script language="javascript" type="text/javascript">
            
function onSucceeded(result)
            {
                alert(result.xml);
            }
        
</script>
    
</form>

//服务端代码

    [WebMethod]
    [ScriptMethod(ResponseFormat 
= ResponseFormat.Xml)]
    
public XmlNode GetXmlDocument()
    {
        XmlDocument doc 
= new XmlDocument();
        doc.LoadXml(
"<Employee><Name>Jeffrey Zhao</Name><Salary>1000</Salary></Employee>");return doc;
    }

    [WebMethod]
    [ScriptMethod(ResponseFormat 

= ResponseFormat.Xml)]
    
public XmlNode GetXmlElement()
    {
        XmlDocument doc 
= new XmlDocument();
        doc.LoadXml(
"<Employee><Name>Jeffrey Zhao</Name><Salary>1000</Salary></Employee>");return doc.DocumentElement;
    }

    [WebMethod]
    [ScriptMethod(ResponseFormat 

= ResponseFormat.Xml)]
    
public Employee GetEmployee()
    {
        
return new Employee("Jeffrey Zhao"1000);
    }

    [WebMethod]
    [ScriptMethod(ResponseFormat 

= ResponseFormat.Xml)]
    
public string GetXmlString()
    {
        
return "<Employee><Name>Jeffrey Zhao</Name><Salary>1000</Salary></Employee>";
    }

    [WebMethod]
    [ScriptMethod(ResponseFormat 

= ResponseFormat.Xml, XmlSerializeString = true)]
    
public string GetSerializedString()
    {
        
return "<Employee><Name>Jeffrey Zhao</Name><Salary>1000</Salary></Employee>";
    }