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

推荐订阅源

宝玉的分享
宝玉的分享
Engineering at Meta
Engineering at Meta
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 聂微东
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 三生石上(FineUI控件)
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
爱范儿
爱范儿
博客园 - 司徒正美
人人都是产品经理
人人都是产品经理
Jina AI
Jina AI
博客园 - 叶小钗
雷峰网
雷峰网
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - Franky
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
阮一峰的网络日志
阮一峰的网络日志
量子位

博客园 - 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>";
    }