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
  • 相关阅读:
    matplotlib的使用——scatter散点图的绘制
    OpenCVPython系列之立体图像的深度图
    YOLOv3 cfg文件详解
    Opencv的使用小教程2——Opencv常用图像处理函数汇总
    数字世界中的纸张——理解 PDF
    go channel初步
    Unity学习记录 导航
    elasticsearch的keyword与text的区别
    markdownitcontainer
    Windows 编译opensll
  • 原文地址:https://www.cnblogs.com/starcrm/p/1351773.html
Copyright © 2011-2022 走看看