zoukankan      html  css  js  c++  java
  • delphi调用webservice (.NET C#版)

     1 uses XMLIntf, XMLDoc;
     2 
     3  
     4 
     5 XML to  XTR文件转换
     6 
     7  
     8 
     9 1、File-->open打开你要分析的XML文件
    10 2、在左边选择你要分析的接点,双击加到中间的转换列表中
    11 3、Create-->DataPacket from XML
    12 4、Create and Test Transformation
    13 5file-->save-->Transformation得到一个.xtr的文件
    14 6、打开.xtr文件,第一行找到"><SelectEach dest="DATAPACKETROWDATAROW" from="EnvelopeBody……>
    15    把‘soap:’、‘diffgr:’删除,保存
    16 7、XMLTransformProvider->transformRead->TransformationFile指向.xtr文件
    17 8、设置ClientDataSet1的ProviderName属性
    18 
    19 =====客户端==============================================================
    20 
    21  必需先
    22 
    23 CEMAI.GetCEMAISoap;
    24 
    25 =============
    26 
    27 procedure TMainfrm.Button1Click(Sender: TObject);
    28 begin
    29   Edit1.Text:=XTRPath ;
    30   HttpRIO1.HTTPWebNode.Agent := 'Borland SOAP 1.2'  ;
    31   HttpRIO1.HTTPWebNode.UseUTF8InHeader  :=  True;
    32   HttpRIO1.Converter.Options  :=  HttpRIO1.Converter.Options  +  [soUTF8InHeader,  soUTF8EncodeXML];
    33   HttpRIO1.Converter.Options := [soSendMultiRefObj, soTryAllSchema, soRootRefNodesToBody, soUTF8InHeader, soCacheMimeResponse, soUTF8EncodeXML];
    34   HttpRio1.Converter.Encoding := 'utf-8' ;
    35   HttpRIO1.URL  :=  defURL;
    36   (HTTPRIO1 as CEMAISoap).GetDataSet(Key,Ssql);
    37 end;
    38 
    39 =========================
    40 
    41 procedure TMainfrm.HTTPRIO1AfterExecute(const MethodName: String;
    42   SOAPResponse: TStream);
    43 var
    44   XMLDoc: IXMLDocument;
    45 begin
    46   SOAPResponse.Position := 0;
    47   ClientDataset1.Active := FALSE;
    48   SOAPResponse.Position := 0;
    49 
    50   XMLDoc := NewXMLDocument;
    51   XMLDoc.Encoding := 'UTF8';
    52   SOAPResponse.Position := 0;
    53   XMLDoc.LoadFromStream(SOAPResponse);
    54   xmlDoc.SaveToFile('c:max.xml');   //保存xml文件到根目录
    55 
    56   XMLTransformProvider1.TransformRead.SourceXmlDocument := XMLDoc.GetDOMDocument;
    57   XMLTransformProvider1.TransformRead.TransformationFile := Edit1.Text;
    58   ClientDataSet1.OPEN ;
    59   ClientDataset1.Active := TRUE;
    60 
    61 end;
    62 
    63 =====服务单元,自动生成=================================
    64 
    65 服务单元,必需在initialization处加一句。
    66 
    67 initialization
    68   InvRegistry.RegisterInvokeOptions(TypeInfo(CEMAISoap),ioDocument) ;
  • 相关阅读:
    打击目标
    面试中的坑,你能爬出来几个?
    [linux] 小问题:管道符,换行问题等;[nginx]启动,重启,关闭命令;以及升级nginx切换命令
    xshell下使用vim的编辑一个文件Ctrl+S和Ctrl+Q
    [PHP] 调用微博API 发微博OAuth2.0
    [YII2] 视图层过滤客户恶意代码
    [YII2] 增删改查2
    [YII2] 增删改查
    [YII2] 自带分页调整
    [JS] 自己弄得个倒计时
  • 原文地址:https://www.cnblogs.com/FKdelphi/p/4633833.html
Copyright © 2011-2022 走看看