zoukankan      html  css  js  c++  java
  • SilverLight学习笔记Web 服务

    编写Web service

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Web;

    using System.Web.Services;

     

    namespace SilverlightApplication10.Web

    {

        /// <summary>

        /// WebService1 的摘要说明

        /// </summary>

        [WebService(Namespace = "http://tempuri.org/")]

        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

        [System.ComponentModel.ToolboxItem(false)]

        // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。

        // [System.Web.Script.Services.ScriptService]

        public class WebService1 : System.Web.Services.WebService

        {

     

            [WebMethod]

            public string GetXML()

            {

                string s;

                s = @"<body IsMember='true'>

                      <form_LRB>

                        <YYSRBQ>3536456.98</YYSRBQ>

                        <YYCBBQ>456798.00</YYCBBQ>

                        <XSFYBQ>3456.00</XSFYBQ>

                        <YYLRBQ>255456.32</YYLRBQ>

                      </form_LRB>

                      <head>

                        <createTime>2008-12-10</createTime>

                        <form>

                          <formId>ADGH4368FDG3465</formId>

                          <instanceId>DG2H9J-DG22HG-ASF42F-55FFG</instanceId>

                        </form>

                      </head>

                      <base>

                        <NSRMC>东莞市愉达玻璃装饰工程有限公司</NSRMC>

                      </base>

                    </body>";

                return s;

            }

        }

    }

    引用代理类

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Net;

    using System.Windows;

    using System.Windows.Controls;

    using System.Windows.Documents;

    using System.Windows.Input;

    using System.Windows.Media;

    using System.Windows.Media.Animation;

    using System.Windows.Shapes;

    using SilverlightApplication10.MyXMLService;

    using System.Xml;

    using System.IO;

     

    namespace SilverlightApplication10

    {

        public partial class Page : UserControl

        {

            public Page()

            {

                InitializeComponent();

                GetService();

            }

     

            private void GetService()

            {

     

                WebService1SoapClient ws = new WebService1SoapClient();

                ws.GetXMLCompleted += new EventHandler<GetXMLCompletedEventArgs>(ws_GetXMLCompleted);

                ws.GetXMLAsync();

            }

     

            void ws_GetXMLCompleted(object sender, GetXMLCompletedEventArgs e)

            {

                if (e.Error == null)

                {

                  using (XmlReader responseReader = XmlReader.Create(new StringReader(e.Result)))

                    {

     

                        responseReader.ReadToFollowing("YYSRBQ");

                        decimal YYSRBQ = responseReader.ReadElementContentAsDecimal();

                        responseReader.ReadToFollowing("YYCBBQ");

                        decimal YYCBBQ = responseReader.ReadElementContentAsDecimal();

                        responseReader.ReadToFollowing("YYLRBQ");

                        decimal YYLRBQ = responseReader.ReadElementContentAsDecimal();

                        responseReader.ReadToFollowing("instanceId");

                        string instanceId = responseReader.ReadInnerXml();

                        responseReader.ReadToFollowing("NSRMC");

                        string name = responseReader.ReadInnerXml();

     

                        OutputText.Text = "表单实例:" + instanceId + ""n" + name + ""n营业收入:" + YYSRBQ + ""n营业成本:" + YYCBBQ + ""n营业利润:" + YYLRBQ;

                    }

                }

            }

     

     

     

        }

    }

    关于作者: 王昕(QQ:475660) 在广州工作生活30余年。十多年开发经验,在Java、即时通讯、NoSQL、BPM、大数据等领域较有经验。
    目前维护的开源产品:https://gitee.com/475660
  • 相关阅读:
    [转]常用数字处理算法的Verilog实现
    [转]Linux必学的60个命令
    [转]4位超前进位加法器代码及原理
    [转]FPGA & Verilog开发经验若干
    [转]Verilog中parameter和define的区别
    [转]VIM标记 mark 详解
    关于获取服务的需求列表
    Office 2007 探索之路 Outlook
    利用反射建立单一调用的WebService
    寻宝记
  • 原文地址:https://www.cnblogs.com/starcrm/p/1351773.html
Copyright © 2011-2022 走看看