国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
在Delphi中使用由.NET開發(fā)的Web Service返回的DataSet類型
在微軟中國(guó)找到了一個(gè)官方的說(shuō)法------不建議將DataSet直接作為返回值傳送,因?yàn)槔锩婧写罅繌?fù)雜的schema以及更改等信息,大部分非.NET語(yǔ)言在解析上有困難。建議使用DataSet.WriteXML方法將簡(jiǎn)化后的XML版本作為一個(gè)WideString回傳。經(jīng)過(guò)試驗(yàn),已經(jīng)在Delphi下輕松通過(guò),Delphi中還需要使用XML Mapper工具事先生成Transfomation(XTR)文件。

Delphi7客戶端代碼
----------------------------------------------------------------------------------------------------------------------------
unit WSTestMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, InvokeRegistry, StdCtrls, Rio, SOAPHTTPClient, Grids, DBGrids,
  DB, DBClient, DBTables, Provider, xmldom, Xmlxform,XMLIntf,XMLDoc,SOAPConst;

type
  TForm1 = class(TForm)
    HTTPRIO1: THTTPRIO;
    Button1: TButton;
    Memo1: TMemo;
    XMLTransformProvider1: TXMLTransformProvider;
    ClientDataSet1: TClientDataSet;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses WSTestDefine;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  A:Service1Soap;
  B:WideString;
  XMLDoc: IXMLDocument;
begin
  A := HTTPRIO1 as Service1Soap;
  B := A.GetPersonTable;
  Memo1.Lines.Add( B );
  ClientDataset1.Active := FALSE;
  XMLDoc := NewXMLDocument;
  XMLDoc.Encoding := SUTF8;
  XMLDoc.LoadFromXML(B);
  XMLTransformProvider1.TransformRead.SourceXmlDocument := XMLDoc.GetDOMDocument;
  ClientDataset1.Active := TRUE;
end;

end.

---------------------------------------------------------------------------------------
.NET WebService代碼
---------------------------------------------------------------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Data.OracleClient;
using System.IO;
namespace WS0622
{
 /// <summary>
 /// Service1 的摘要說(shuō)明。
 /// </summary>

 public class Service1 : System.Web.Services.WebService
 {
  public Service1()
  {
  //CODEGEN: 該調(diào)用是 ASP.NET Web 服務(wù)設(shè)計(jì)器所必需的
   InitializeComponent();
  }

  #region 組件設(shè)計(jì)器生成的代碼
 
  //Web 服務(wù)設(shè)計(jì)器所必需的
  private IContainer components = null;
    
  /// <summary>
  /// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器修改
  /// 此方法的內(nèi)容。
  /// </summary>

  private void InitializeComponent()
  {

  }

  /// <summary>
  /// 清理所有正在使用的資源。
  /// </summary>

  protected override void Dispose( bool disposing )
  {
   if(disposing && components != null)
   {
    components.Dispose();
   }
   base.Dispose(disposing);  
  }
 
  #endregion

  // WEB 服務(wù)示例
  // HelloWorld() 示例服務(wù)返回字符串 Hello World
  // 若要生成,請(qǐng)取消注釋下列行,然后保存并生成項(xiàng)目
  // 若要測(cè)試此 Web 服務(wù),請(qǐng)按 F5 鍵


  [Serializable]
   public class Person
  {
   public Person()
   {
   }

   public Person(string name,string gender)
   {
    this.Name=name;
    this.Gender=gender;
   }

   public string Name="";
   public string Gender="";
  }
  [WebMethod(CacheDuration=60)]
  public Person[] GetPersons()
  {
   Person Alice=new Person("Alice","Female");
   Person Bob=new Person("Bob","Male");
   Person Chris=new Person("Chris","Female");
   Person Dennis=new Person("Dennis","Male");

   return new Person[]{Alice,Bob,Chris,Dennis};
  }

  [WebMethod]
  public string GetPersonTable()
  {
   DataTable table=new DataTable("Person");  
   table.Columns.Add("Name");
   table.Columns.Add("Gender");
   table.Rows.Add(new string[2]{"Alice","Female"});
   table.Rows.Add(new string[2]{"Bob","Male"});
   table.Rows.Add(new string[2]{"Chris","Female"});
   table.Rows.Add(new string[2]{"Dennis","Male"});
   table.Rows.Add(new string[2]{"Eric","Male"});
 
   DataSet dataset=new DataSet("PersonTable");
   dataset.Tables.Add(table);
 
   System.Text.StringBuilder strbuilder=new System.Text.StringBuilder();
   StringWriter writer=new StringWriter(strbuilder);
   dataset.WriteXml(writer,System.Data.XmlWriteMode.IgnoreSchema);
   return strbuilder.ToString();
  }
 }
}


Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=300422

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
delphi 調(diào)用 C#寫的webservice
Java調(diào)用.net的WebService - 阿善的日志 - 網(wǎng)易博客
Using DataSnap Importer to work with datasets
《ASP.NET辦公自動(dòng)化系統(tǒng)開發(fā)實(shí)例導(dǎo)航》筆記二 系統(tǒng)管理模塊設(shè)計(jì)
通過(guò)壓縮SOAP改善XML Web service性能
web service實(shí)現(xiàn)原理與異步調(diào)用
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服