我现在用C#作了个WEB SERVICE已经发布,在VB,.NET,ASP等中调用好使,可是在DELPHI中怎样调用啊!!!我已经用DELPHI的web services importer导入了WSDL文件生成了unit2,unit3两个文件
Unit Unit2;interfaceuses InvokeRegistry, Types, XSBuiltIns;type  Digestfirst = class;
  DigestfirstResponse = class;
  Digestdata = class;
  DigestdataResponse = class;
  stru = class;
  vfysigndata = class;
  vfysigndataResponse = class;
  vfystru = class;{ Digestfirst }  Digestfirst = class(TRemotable)
  private
    Ffirstdata: WideString;
  published
    property firstdata: WideString read Ffirstdata write Ffirstdata;
  end;{ DigestfirstResponse }  DigestfirstResponse = class(TRemotable)
  private
    FDigestfirstResult: WideString;
  published
    property DigestfirstResult: WideString read FDigestfirstResult write FDigestfirstResult;
  end;{ Digestdata }  Digestdata = class(TRemotable)
  private
    Fsourcedata: WideString;
  published
    property sourcedata: WideString read Fsourcedata write Fsourcedata;
  end;{ DigestdataResponse }  DigestdataResponse = class(TRemotable)
  private
    FDigestdataResult: stru;
  published
    property DigestdataResult: stru read FDigestdataResult write FDigestdataResult;
  end;{ stru }  stru = class(TRemotable)
  private
    Fone: WideString;
    Ftwo: WideString;
    Fthree: WideString;
  published
    property one: WideString read Fone write Fone;
    property two: WideString read Ftwo write Ftwo;
    property three: WideString read Fthree write Fthree;
  end;{ vfysigndata }  vfysigndata = class(TRemotable)
  private
    Fsourcedigestdata: WideString;
    Ftimedata: WideString;
    Ftimedigest: WideString;
    Fsigndata: WideString;
  published
    property sourcedigestdata: WideString read Fsourcedigestdata write Fsourcedigestdata;
    property timedata: WideString read Ftimedata write Ftimedata;
    property timedigest: WideString read Ftimedigest write Ftimedigest;
    property signdata: WideString read Fsigndata write Fsigndata;
  end;{ vfysigndataResponse }  vfysigndataResponse = class(TRemotable)
  private
    FvfysigndataResult: vfystru;
  published
    property vfysigndataResult: vfystru read FvfysigndataResult write FvfysigndataResult;
  end;{ vfystru }  vfystru = class(TRemotable)
  private
    Fsucceed: WideString;
    Flastbacktime: WideString;
  published
    property succeed: WideString read Fsucceed write Fsucceed;
    property lastbacktime: WideString read Flastbacktime write Flastbacktime;
  end;
implementationinitialization
  RemClassRegistry.RegisterXSInfo(TypeInfo(Digestfirst),'http://localhost/WebService1/','Digestfirst','');
  RemClassRegistry.RegisterXSInfo(TypeInfo(DigestfirstResponse),'http://localhost/WebService1/','DigestfirstResponse','');
  RemClassRegistry.RegisterXSInfo(TypeInfo(Digestdata),'http://localhost/WebService1/','Digestdata','');
  RemClassRegistry.RegisterXSInfo(TypeInfo(DigestdataResponse),'http://localhost/WebService1/','DigestdataResponse','');
  RemClassRegistry.RegisterXSInfo(TypeInfo(vfysigndata),'http://localhost/WebService1/','vfysigndata','');
  RemClassRegistry.RegisterXSInfo(TypeInfo(vfysigndataResponse),'http://localhost/WebService1/','vfysigndataResponse','');
  RemClassRegistry.RegisterXSInfo(TypeInfo(stru),'http://localhost/WebService1/','stru','');
  RemClassRegistry.RegisterXSInfo(TypeInfo(vfystru),'http://localhost/WebService1/','vfystru','');
  RemClassRegistry.RegisterXSClass(Digestfirst,'http://localhost/WebService1/','Digestfirst','');
  RemClassRegistry.RegisterXSClass(DigestfirstResponse,'http://localhost/WebService1/','DigestfirstResponse','');
  RemClassRegistry.RegisterXSClass(Digestdata,'http://localhost/WebService1/','Digestdata','');
  RemClassRegistry.RegisterXSClass(DigestdataResponse,'http://localhost/WebService1/','DigestdataResponse','');
  RemClassRegistry.RegisterXSClass(stru,'http://localhost/WebService1/','stru','');
  RemClassRegistry.RegisterXSClass(vfysigndata,'http://localhost/WebService1/','vfysigndata','');
  RemClassRegistry.RegisterXSClass(vfysigndataResponse,'http://localhost/WebService1/','vfysigndataResponse','');
  RemClassRegistry.RegisterXSClass(vfystru,'http://localhost/WebService1/','vfystru','');end.Unit Unit3;interfaceuses Types, XSBuiltIns, Unit2;
type  AutoService1Soap = interface(IInvokable)
    ['{C9309023-1917-4227-84DB-27F99A6A00EA}']
    procedure Digestfirst(var parameters: Digestfirst);  stdcall;
    procedure Digestdata(var parameters: Digestdata);  stdcall;
    procedure vfysigndata(var parameters: vfysigndata);  stdcall;
  end;
  AutoService1HttpGet = interface(IInvokable)
    ['{528F8BDE-9932-4E16-A22D-E1499FDA6FF1}']
    procedure Digestfirst(const firstdata: WideString; out Body: WideString);  stdcall;
    procedure Digestdata(const sourcedata: WideString; out Body: stru);  stdcall;
    procedure vfysigndata(const sourcedigestdata: WideString; const timedata: WideString; const timedigest: WideString; const signdata: WideString; out Body: vfystru);  stdcall;
  end;
  AutoService1HttpPost = interface(IInvokable)
    ['{51F3019A-9A98-45A2-9F27-1993F32866BA}']
    procedure Digestfirst(const firstdata: WideString; out Body: WideString);  stdcall;
    procedure Digestdata(const sourcedata: WideString; out Body: stru);  stdcall;
    procedure vfysigndata(const sourcedigestdata: WideString; const timedata: WideString; const timedigest: WideString; const signdata: WideString; out Body: vfystru);  stdcall;
  end;
implementationuses InvokeRegistry;initialization
  InvRegistry.RegisterInterface(TypeInfo(AutoService1Soap), '', 'utf-8');
InvRegistry.RegisterInterface(TypeInfo(AutoService1HttpGet), '', 'utf-8');
InvRegistry.RegisterInterface(TypeInfo(AutoService1HttpPost), '', 'utf-8');end.可是我怎么调用呢??我想调用web service 的 Digestfirst方法???请赐教!!拜谢

解决方案 »

  1.   

    Web Service返回给你的是XML格式的字符流,即便是用最笨的字符搜索也能解决问题呀,更何况还有这么多产生、处理Web Service的控件呢。
      

  2.   

    你先建立一個項目﹐然后收用這這個接口定議的unit,然后調用這個方法就可以了
      

  3.   

    Delphi 7 好像不生成这样的吧。 不如贴上wsdl来试试看
      

  4.   

    WSDL文件如下:
     <?xml version="1.0" encoding="utf-8" ?> 
    - <definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="http://localhost/WebService1/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://localhost/WebService1/" xmlns="http://schemas.xmlsoap.org/wsdl/">
    - <types>
    - <s:schema elementFormDefault="qualified" targetNamespace="http://localhost/WebService1/">
    - <s:element name="Digestfirst">
    - <s:complexType>
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="firstdata" type="s:string" /> 
      </s:sequence>
      </s:complexType>
      </s:element>
    - <s:element name="DigestfirstResponse">
    - <s:complexType>
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="DigestfirstResult" type="s:string" /> 
      </s:sequence>
      </s:complexType>
      </s:element>
    - <s:element name="Digestdata">
    - <s:complexType>
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="sourcedata" type="s:string" /> 
      </s:sequence>
      </s:complexType>
      </s:element>
    - <s:element name="DigestdataResponse">
    - <s:complexType>
    - <s:sequence>
      <s:element minOccurs="1" maxOccurs="1" name="DigestdataResult" type="s0:stru" /> 
      </s:sequence>
      </s:complexType>
      </s:element>
    - <s:complexType name="stru">
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="one" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="two" type="s:string" /> 
      <s:element minOccurs="1" maxOccurs="1" name="three" type="s:dateTime" /> 
      </s:sequence>
      </s:complexType>
    - <s:element name="vfysigndata">
    - <s:complexType>
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="sourcedigestdata" type="s:string" /> 
      <s:element minOccurs="1" maxOccurs="1" name="timedata" type="s:dateTime" /> 
      <s:element minOccurs="0" maxOccurs="1" name="timedigest" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="signdata" type="s:string" /> 
      </s:sequence>
      </s:complexType>
      </s:element>
    - <s:element name="vfysigndataResponse">
    - <s:complexType>
    - <s:sequence>
      <s:element minOccurs="1" maxOccurs="1" name="vfysigndataResult" type="s0:vfystru" /> 
      </s:sequence>
      </s:complexType>
      </s:element>
    - <s:complexType name="vfystru">
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="succeed" type="s:string" /> 
      <s:element minOccurs="1" maxOccurs="1" name="lastbacktime" type="s:dateTime" /> 
      </s:sequence>
      </s:complexType>
      <s:element name="string" nillable="true" type="s:string" /> 
      <s:element name="stru" type="s0:stru" /> 
      <s:element name="vfystru" type="s0:vfystru" /> 
      </s:schema>
      </types>
      

  5.   


    - <message name="DigestfirstSoapIn">
      <part name="parameters" element="s0:Digestfirst" /> 
      </message>
    - <message name="DigestfirstSoapOut">
      <part name="parameters" element="s0:DigestfirstResponse" /> 
      </message>
    - <message name="DigestdataSoapIn">
      <part name="parameters" element="s0:Digestdata" /> 
      </message>
    - <message name="DigestdataSoapOut">
      <part name="parameters" element="s0:DigestdataResponse" /> 
      </message>
    - <message name="vfysigndataSoapIn">
      <part name="parameters" element="s0:vfysigndata" /> 
      </message>
    - <message name="vfysigndataSoapOut">
      <part name="parameters" element="s0:vfysigndataResponse" /> 
      </message>
    - <message name="DigestfirstHttpGetIn">
      <part name="firstdata" type="s:string" /> 
      </message>
    - <message name="DigestfirstHttpGetOut">
      <part name="Body" element="s0:string" /> 
      </message>
    - <message name="DigestdataHttpGetIn">
      <part name="sourcedata" type="s:string" /> 
      </message>
    - <message name="DigestdataHttpGetOut">
      <part name="Body" element="s0:stru" /> 
      </message>
    - <message name="vfysigndataHttpGetIn">
      <part name="sourcedigestdata" type="s:string" /> 
      <part name="timedata" type="s:string" /> 
      <part name="timedigest" type="s:string" /> 
      <part name="signdata" type="s:string" /> 
      </message>
    - <message name="vfysigndataHttpGetOut">
      <part name="Body" element="s0:vfystru" /> 
      </message>
    - <message name="DigestfirstHttpPostIn">
      <part name="firstdata" type="s:string" /> 
      </message>
    - <message name="DigestfirstHttpPostOut">
      <part name="Body" element="s0:string" /> 
      </message>
    - <message name="DigestdataHttpPostIn">
      <part name="sourcedata" type="s:string" /> 
      </message>
    - <message name="DigestdataHttpPostOut">
      <part name="Body" element="s0:stru" /> 
      </message>
    - <message name="vfysigndataHttpPostIn">
      <part name="sourcedigestdata" type="s:string" /> 
      <part name="timedata" type="s:string" /> 
      <part name="timedigest" type="s:string" /> 
      <part name="signdata" type="s:string" /> 
      </message>
    - <message name="vfysigndataHttpPostOut">
      <part name="Body" element="s0:vfystru" /> 
      </message>
    - <portType name="AutoService1Soap">
    - <operation name="Digestfirst">
      <input message="s0:DigestfirstSoapIn" /> 
      <output message="s0:DigestfirstSoapOut" /> 
      </operation>
    - <operation name="Digestdata">
      <input message="s0:DigestdataSoapIn" /> 
      <output message="s0:DigestdataSoapOut" /> 
      </operation>
    - <operation name="vfysigndata">
      <input message="s0:vfysigndataSoapIn" /> 
      <output message="s0:vfysigndataSoapOut" /> 
      </operation>
      </portType>
    - <portType name="AutoService1HttpGet">
    - <operation name="Digestfirst">
      <input message="s0:DigestfirstHttpGetIn" /> 
      <output message="s0:DigestfirstHttpGetOut" /> 
      </operation>
    - <operation name="Digestdata">
      <input message="s0:DigestdataHttpGetIn" /> 
      <output message="s0:DigestdataHttpGetOut" /> 
      </operation>
    - <operation name="vfysigndata">
      <input message="s0:vfysigndataHttpGetIn" /> 
      <output message="s0:vfysigndataHttpGetOut" /> 
      </operation>
      </portType>
    - <portType name="AutoService1HttpPost">
    - <operation name="Digestfirst">
      <input message="s0:DigestfirstHttpPostIn" /> 
      <output message="s0:DigestfirstHttpPostOut" /> 
      </operation>
    - <operation name="Digestdata">
      <input message="s0:DigestdataHttpPostIn" /> 
      <output message="s0:DigestdataHttpPostOut" /> 
      </operation>
    - <operation name="vfysigndata">
      <input message="s0:vfysigndataHttpPostIn" /> 
      <output message="s0:vfysigndataHttpPostOut" /> 
      </operation>
      </portType>
    - <binding name="AutoService1Soap" type="s0:AutoService1Soap">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
    - <operation name="Digestfirst">
      <soap:operation soapAction="http://localhost/WebService1/Digestfirst" style="document" /> 
    - <input>
      <soap:body use="literal" /> 
      </input>
    - <output>
      <soap:body use="literal" /> 
      </output>
      </operation>
    - <operation name="Digestdata">
      <soap:operation soapAction="http://localhost/WebService1/Digestdata" style="document" /> 
    - <input>
      <soap:body use="literal" /> 
      </input>
    - <output>
      <soap:body use="literal" /> 
      </output>
      </operation>
    - <operation name="vfysigndata">
      <soap:operation soapAction="http://localhost/WebService1/vfysigndata" style="document" /> 
    - <input>
      <soap:body use="literal" /> 
      </input>
    - <output>
      <soap:body use="literal" /> 
      </output>
      </operation>
      </binding>
    - <binding name="AutoService1HttpGet" type="s0:AutoService1HttpGet">
      <http:binding verb="GET" /> 
    - <operation name="Digestfirst">
      <http:operation location="/Digestfirst" /> 
    - <input>
      <http:urlEncoded /> 
      </input>
    - <output>
      <mime:mimeXml part="Body" /> 
      </output>
      </operation>
    - <operation name="Digestdata">
      <http:operation location="/Digestdata" /> 
    - <input>
      <http:urlEncoded /> 
      </input>
    - <output>
      <mime:mimeXml part="Body" /> 
      </output>
      </operation>
    - <operation name="vfysigndata">
      <http:operation location="/vfysigndata" /> 
    - <input>
      <http:urlEncoded /> 
      </input>
    - <output>
      <mime:mimeXml part="Body" /> 
      </output>
      </operation>
      </binding>
    - <binding name="AutoService1HttpPost" type="s0:AutoService1HttpPost">
      <http:binding verb="POST" /> 
    - <operation name="Digestfirst">
      <http:operation location="/Digestfirst" /> 
    - <input>
      <mime:content type="application/x-www-form-urlencoded" /> 
      </input>
    - <output>
      <mime:mimeXml part="Body" /> 
      </output>
      </operation>
    - <operation name="Digestdata">
      <http:operation location="/Digestdata" /> 
    - <input>
      <mime:content type="application/x-www-form-urlencoded" /> 
      </input>
    - <output>
      <mime:mimeXml part="Body" /> 
      </output>
      </operation>
    - <operation name="vfysigndata">
      <http:operation location="/vfysigndata" /> 
    - <input>
      <mime:content type="application/x-www-form-urlencoded" /> 
      </input>
    - <output>
      <mime:mimeXml part="Body" /> 
      </output>
      </operation>
      </binding>
    + <service name="AutoService1">
      <documentation>时间戳服务</documentation> 
    - <port name="AutoService1Soap" binding="s0:AutoService1Soap">
      <soap:address location="http://localhost/WebService1/Service1.asmx" /> 
      </port>
    - <port name="AutoService1HttpGet" binding="s0:AutoService1HttpGet">
      <http:address location="http://localhost/WebService1/Service1.asmx" /> 
      </port>
    - <port name="AutoService1HttpPost" binding="s0:AutoService1HttpPost">
      <http:address location="http://localhost/WebService1/Service1.asmx" /> 
      </port>
      </service>
      </definitions>