uses XMLIntf, XMLDoc;
XML to XTR文件转换
、File-->open打开你要分析的XML文件
、在左边选择你要分析的接点,双击加到中间的转换列表中
、Create-->DataPacket from XML
、Create and Test Transformation
、file-->save-->Transformation得到一个.xtr的文件
、打开.xtr文件,第一行找到"><SelectEach dest="DATAPACKET\ROWDATA\ROW" from="\Envelope\Body\……>
把‘soap:’、‘diffgr:’删除,保存
、XMLTransformProvider->transformRead->TransformationFile指向.xtr文件
、设置ClientDataSet1的ProviderName属性
=====客户端==============================================================
必需先
CEMAI.GetCEMAISoap;
=============
procedure TMainfrm.Button1Click(Sender: TObject);
begin
Edit1.Text:=XTRPath ;
HttpRIO1.HTTPWebNode.Agent := 'Borland SOAP 1.2' ;
HttpRIO1.HTTPWebNode.UseUTF8InHeader := True;
HttpRIO1.Converter.Options := HttpRIO1.Converter.Options + [soUTF8InHeader, soUTF8EncodeXML];
HttpRIO1.Converter.Options := [soSendMultiRefObj, soTryAllSchema, soRootRefNodesToBody, soUTF8InHeader, soCacheMimeResponse, soUTF8EncodeXML];
HttpRio1.Converter.Encoding := 'utf-8' ;
HttpRIO1.URL := defURL;
(HTTPRIO1 as CEMAISoap).GetDataSet(Key,Ssql);
end;
=========================
procedure TMainfrm.HTTPRIO1AfterExecute(const MethodName: String;
SOAPResponse: TStream);
var
XMLDoc: IXMLDocument;
begin
SOAPResponse.Position := ;
ClientDataset1.Active := FALSE;
SOAPResponse.Position := ;
XMLDoc := NewXMLDocument;
XMLDoc.Encoding := 'UTF8';
SOAPResponse.Position := ;
XMLDoc.LoadFromStream(SOAPResponse);
xmlDoc.SaveToFile('c:\max.xml'); //保存xml文件到根目录
XMLTransformProvider1.TransformRead.SourceXmlDocument := XMLDoc.GetDOMDocument;
XMLTransformProvider1.TransformRead.TransformationFile := Edit1.Text;
ClientDataSet1.OPEN ;
ClientDataset1.Active := TRUE;
end;
=====服务单元,自动生成=================================
服务单元,必需在initialization处加一句。
initialization
InvRegistry.RegisterInvokeOptions(TypeInfo(CEMAISoap),ioDocument) ;