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

推荐订阅源

U
Unit 42
罗磊的独立博客
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
博客园 - 司徒正美
Stack Overflow Blog
Stack Overflow Blog
F
Fortinet All Blogs
A
About on SuperTechFans
腾讯CDC
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed
IT之家
IT之家
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
宝玉的分享
宝玉的分享
C
Check Point Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Vercel News
Vercel News
爱范儿
爱范儿
Microsoft Security Blog
Microsoft Security Blog
月光博客
月光博客
T
Tailwind CSS Blog
The Cloudflare Blog
Hugging Face - Blog
Hugging Face - 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>";
    }