【问题标题】:Delphi: WSDL objects not included in WSDL fileDelphi:WSDL 文件中不包含 WSDL 对象
【发布时间】:2012-09-18 06:09:11
【问题描述】:

我正在尝试在 C# 中创建一个 WCF 服务,以供使用 Delphi 构建的客户端应用程序使用。在 Delphi 中下载 WSDL 时,Delphi 生成的文件中不包含任何对象。

当导入到 Delphi 时,我必须在 C# 中做什么才能在 WSDL 中声明对象?

编辑

我在 C# 中使用 EntityFramework 从数据库生成类(它是一个现有的数据库,所以请不要告诉我我应该先编写代码)。以下是其中一个类文件的示例:

namespace LeadVendorModel
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;

    public partial class T_LeadVendorEmailDetail : DbContext
    {
        public int LeadVendorEmailDetailID { get; set; }
        public int LeadVendorEmailID { get; set; }
        public string Field_label { get; set; }
        public string Field_Data { get; set; }
        public Nullable<System.DateTime> EnteredOn { get; set; }

        public virtual T_LeadVendorEmailHeader T_LeadVendorEmailHeaders { get; set; }
    }
}

我只是在 C# 项目中使用“发布”操作来发布项目。我不确定我还会在哪里定义 Delphi 抱怨的类型/对象。是否有需要添加到 Web.config 的 XML 设置?

我很乐意提供所需的任何其他信息,只是不确定还有什么帮助(第一次使用 EF 和第一次创建 API)。

结束编辑

这是生成文件的 sn-p(未创建对象):

unit LeadService;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

type

  // ************************************************************************ //
  // The following types, referred to in the WSDL document are not being represented
  // in this file. They are either aliases[@] of other types represented or were referred
  // to but never[!] declared in the document. The types from the latter category
  // typically map to predefined/known XML or Borland types; however, they could also
  // indicate incorrect WSDL documents that failed to declare or import a schema type.
  // ************************************************************************ //
  // !:GetFranchiseDetails - "http://tempuri.org/"
  // !:GetFranchiseDetailsResponse - "http://tempuri.org/"
  // !:FranchiseExists - "http://tempuri.org/"
  // !:FranchiseExistsResponse - "http://tempuri.org/"
  // !:GetLeadDetails  - "http://tempuri.org/"
  // !:GetLeadDetailsResponse - "http://tempuri.org/"
  // !:GetLookupList   - "http://tempuri.org/"
  // !:GetLookupListResponse - "http://tempuri.org/"
  // !:SubmitLead      - "http://tempuri.org/"
  // !:SubmitLeadResponse - "http://tempuri.org/"
  // !:SubmitLeadAction - "http://tempuri.org/"
  // !:SubmitLeadActionResponse - "http://tempuri.org/"
  // !:SubmitLeadOutcome - "http://tempuri.org/"
  // !:SubmitLeadOutcomeResponse - "http://tempuri.org/"


  // ************************************************************************ //
  // Namespace : http://tempuri.org/
  // binding   : wsHttpBinding
  // service   : LeadService
  // port      : wsHttpBinding
  // ************************************************************************ //
  ILeadService = interface(IInvokable)
  ['{C61A5600-2BA8-436A-41AA-F81C45A9A738}']
    function  GetFranchiseDetails(const parameters: GetFranchiseDetails): GetFranchiseDetailsResponse; stdcall;
    function  FranchiseExists(const parameters: FranchiseExists): FranchiseExistsResponse; stdcall;
    function  GetLeadDetails(const parameters: GetLeadDetails): GetLeadDetailsResponse; stdcall;
    function  GetLookupList(const parameters: GetLookupList): GetLookupListResponse; stdcall;
    function  SubmitLead(const parameters: SubmitLead): SubmitLeadResponse; stdcall;
    function  SubmitLeadAction(const parameters: SubmitLeadAction): SubmitLeadActionResponse; stdcall;
    function  SubmitLeadOutcome(const parameters: SubmitLeadOutcome): SubmitLeadOutcomeResponse; stdcall;
  end;

function GetILeadService(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): ILeadService;

这是另一个 Delphi 生成的文件的 sn-p,其中包含对象定义:

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

type

  // ************************************************************************ //
  // The following types, referred to in the WSDL document are not being represented
  // in this file. They are either aliases[@] of other types represented or were referred
  // to but never[!] declared in the document. The types from the latter category
  // typically map to predefined/known XML or Borland types; however, they could also
  // indicate incorrect WSDL documents that failed to declare or import a schema type.
  // ************************************************************************ //
  // !:dateTime        - "http://www.w3.org/2001/XMLSchema"
  // !:int             - "http://www.w3.org/2001/XMLSchema"
  // !:boolean         - "http://www.w3.org/2001/XMLSchema"
  // !:decimal         - "http://www.w3.org/2001/XMLSchema"
  // !:string          - "http://www.w3.org/2001/XMLSchema"

  CompanyID            = class;                 { "http://..." }
  Address              = class;                 { "http://..." }
  Property_            = class;                 { "http://..." }
  AppointmentRequest   = class;                 { "http://..." }


  { "http://..." }
  PersonServiceRoleID = (
      BuyersAgent, 
      SellersAgent, 
      SellersLawyer, 
      BuyersLawyer, 
      Seller,
      Buyer, 
      Owner, 
      Tenant, 
      TransactionCoordinator, 
      RelocationCoordinator, 
      ReferredBy,
      ContractorAdministrator, 
      InsuranceAgent, 
      Contractor,
      PropertyManagement, 
      Buyer1,
      Seller1, 
      Owner1, 
      Tenant1
);

  { "http://..." }
  PersonSearchCriteriaActiveType = (DeletedOnly, Both, UndeletedOnly);

  ArrayOfInt = array of Integer;                { "http://..." }


  // ************************************************************************ //
  // Namespace : http://...
  // ************************************************************************ //
  CompanyID = class(TRemotable)
  private
    FServiceCompanyID: Integer;
  published
    property ServiceCompanyID: Integer read FServiceCompanyID write FServiceCompanyID;
  end;


  // ************************************************************************ //
  // Namespace : http://...
  // soapAction: http://...
  // transport : http://schemas.xmlsoap.org/soap/http
  // binding   : CompanySoap
  // service   : Company
  // port      : CompanySoap
  // URL       : http://...
  // ************************************************************************ //
  CompanySoap= interface(IInvokable)
  ['{44A8B9BE-7E75-8534-279B-46BF5D1674D7}']
    function  GetAvailableAppointments(const appointmentRequest: AppointmentRequest; const companyID: CompanyID): ArrayOfAppointmentSlot; stdcall;
    function  GetQuote(const quoteRequest: QuoteRequest; const companyID: CompanyID): ServiceFee; stdcall;
    function  GetPropertyTypes(const companyID: CompanyID): ArrayOfPropertyType; stdcall;
    function  GetFoundationTypes(const companyID: CompanyID): ArrayOfFoundationType; stdcall;
    function  GetServiceTypes(const companyID: CompanyID): ArrayOfServiceType; stdcall;
    function  GetServiceProfessionals(const companyID: CompanyID): ArrayOfInspectorDetails; stdcall;
    function  ScheduleAppointment(const appointmentslot: AppointmentSlot; const customer: Contact; const companyID: CompanyID; const Quote: QuoteRequest; const agent: ArrayOfServiceAgent): AppointmentInfo; stdcall;
    function  FindAppointment(const contactID: Integer; const companyID: CompanyID): ArrayOfAppointmentInfo; stdcall;
    procedure CancelAppointment(const companyID: CompanyID; const appointmentID: Integer); stdcall;
    function  CustomerLookUp(const criteria: PersonSearchCriteria): ArrayOfContact; stdcall;
    function  AddContact(const customer: Contact; const companyID: CompanyID): Contact; stdcall;
    function  UpdateContact(const customer: Contact; const companyID: CompanyID): Contact; stdcall;
    function  ProcessCompanyID(const serviceCompanyID: CompanyID): CompanyID; stdcall;
  end;

function GetCompanySoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): CompanySoap;

【问题讨论】:

  • 您是否阅读了文件顶部关于未创建类型的大注释块以及它们的列表?它解释了为什么没有创建它们 - 因为领先的 !,它们从未被声明。评论说这可能表明错误的 WSDL 文档未能声明或导入模式。您的服务是声明一个模式还是从某个地方导入一个模式?所有跳过的课程都使用tempuri.org
  • 我看到了那条评论,这就是为什么我认为我必须在 C# 中做一些声明才能生成这些对象。
  • 但是你没有从你的 C# 中发布任何东西,我们可以看到你错过了什么......??? “我知道我遗漏了一些东西,但我不会向你展示我目前拥有的东西。请告诉我我需要做些什么来修复它。” - 这是你的问题吗?
  • 您可以使用 wsdl 验证器或内置 wsdl 验证器的 xml 编辑器,例如 xmlspy。它附带 30 天试用期。验证器将为您提供错误/警告/提示,帮助您修复 wsdl 文件。
  • @JeroenWiertPluimers,我可能应该。可能发生的最糟糕的情况是它不被接受或遭到一两次反对,我认为这是布赖恩在这里遇到的问题。

标签: wcf delphi c#-4.0 delphi-7


【解决方案1】:

文件顶部的大注释块解释了未创建的类型及其列表。它解释了为什么没有创建它们 - 因为前导 !,它表明它们从未被声明过。

评论说这可能表明错误的 WSDL 文档未能声明或导入架构。您的服务是声明一个模式还是从某个地方导入一个模式?所有跳过的类都使用 tempuri.org,这不是在您的服务中使用的有效命名空间。

【讨论】:

  • 感谢所有 cmets,请参阅对原始帖子的编辑,如果有任何其他信息可以帮助解决这个问题,我很乐意提供,只是不确定还有什么帮助。跨度>
  • 忘了提到我在整个项目中搜索了“tempuri”,唯一找到对它的引用的地方是一个名为 SdrConfigExample.e2e 的文件,它是一个生成的文件。跨度>
猜你喜欢
  • 1970-01-01
  • 2013-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-14
  • 2013-05-12
  • 2020-10-09
相关资源
最近更新 更多