Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将wsdl从c#.net代码导入delphi不会';不能生成所有字段_C#_Delphi_Delphi 7 - Fatal编程技术网

将wsdl从c#.net代码导入delphi不会';不能生成所有字段

将wsdl从c#.net代码导入delphi不会';不能生成所有字段,c#,delphi,delphi-7,C#,Delphi,Delphi 7,我有D7。我已下载wsdlImp程序: Borland WSDLIMP版本2.2-$Rev:10138$(与delphi 2007一起提供),看起来 使用D7 我有如下c#接口: using System; using System.ServiceModel; [ServiceContract] public interface ITransferService { [OperationContract] RemoteFileInfo DownloadFile(DownloadRequ

我有D7。我已下载wsdlImp程序: Borland WSDLIMP版本2.2-$Rev:10138$(与delphi 2007一起提供),看起来 使用D7

我有如下c#接口:

using System;
using System.ServiceModel;

[ServiceContract]
public interface ITransferService
{
  [OperationContract]
  RemoteFileInfo DownloadFile(DownloadRequest request);

  [OperationContract]
  void UploadFile(RemoteFileInfo request);
}
[MessageContract]
public class DownloadRequest
{
  [MessageBodyMember]
  public string FileName;
}

[MessageContract]
public class RemoteFileInfo : IDisposable
{
  [MessageHeader(MustUnderstand = true)]
  public string FileName;

  [MessageHeader(MustUnderstand = true)]
  public long Length;

  [MessageBodyMember(Order = 1)]
  public System.IO.Stream FileByteStream;

  public void Dispose()
  {
    if (FileByteStream != null)
    {
      FileByteStream.Close();
      FileByteStream = null;
    }
  }
}
Delphi wsdl导入生成:

unit TransferService;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

const
  IS_OPTN = $0001;
  IS_NLBL = $0004;
  IS_REF  = $0080;         

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.
  // ************************************************************************ //
  // !:base64Binary    - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:string          - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:long            - "http://www.w3.org/2001/XMLSchema"[Gbl]

  DownloadRequest      = class;                 { "http://tempuri.org/"[Lit][GblElm] }
  RemoteFileInfo       = class;                 { "http://tempuri.org/"[Lit][GblElm] }
  FileName             = class;                 { "http://tempuri.org/"[Hdr][Alias] }
  Length               = class;                 { "http://tempuri.org/"[Hdr][Alias] }

  StreamBody      =  TByteDynArray;      { "http://schemas.microsoft.com/Message"[GblSmpl] }


  // ************************************************************************ //
  // XML       : DownloadRequest, global, <element>
  // Namespace : http://tempuri.org/
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  DownloadRequest = class(TRemotable)
  private
    FFileName: WideString;
    FFileName_Specified: boolean;
    procedure SetFileName(Index: Integer; const AWideString: WideString);
    function  FileName_Specified(Index: Integer): boolean;
  public
    constructor Create; override;
  published
    property FileName: WideString  Index (IS_OPTN or IS_NLBL) read FFileName write SetFileName stored FileName_Specified;
  end;



  // ************************************************************************ //
  // XML       : RemoteFileInfo, global, <element>
  // Namespace : http://tempuri.org/
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  RemoteFileInfo = class(TRemotable)
  private
    FFileByteStream: StreamBody;
  public
    constructor Create; override;
  published
    property FileByteStream: StreamBody  read FFileByteStream write FFileByteStream;
  end;



  // ************************************************************************ //
  // XML       : FileName, alias
  // Namespace : http://tempuri.org/
  // Serializtn: [xoSimpleTypeWrapper]
  // Info      : Header
  // ************************************************************************ //
  FileName = class(TSOAPHeader)
  private
    FValue: WideString;
  published
    property Value: WideString  read FValue write FValue;
  end;



  // ************************************************************************ //
  // XML       : Length, alias
  // Namespace : http://tempuri.org/
  // Serializtn: [xoSimpleTypeWrapper]
  // Info      : Header
  // ************************************************************************ //
  Length = class(TSOAPHeader)
  private
    FValue: Int64;
  published
    property Value: Int64  read FValue write FValue;
  end;


  // ************************************************************************ //
  // Namespace : http://tempuri.org/
  // soapAction: http://tempuri.org/ITransferService/%operationName%
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : document
  // binding   : BasicHttpBinding_ITransferService
  // service   : TransferService
  // port      : BasicHttpBinding_ITransferService
  // URL       : http://localhost:1875/TransferService.svc
  // ************************************************************************ //
  ITransferService = interface(IInvokable)
  ['{8D28E73C-15D9-7F1E-9D04-A024598C5EA2}']

    // Cannot unwrap: 
    //     - Input element wrapper name does not match operation's name
    // Headers: FileName:pOut, Length:pOut
    function  DownloadFile(const parameters: DownloadRequest): RemoteFileInfo; stdcall;

    // Cannot unwrap: 
    //     - Input element wrapper name does not match operation's name
    // Headers: FileName:pIn, Length:pIn
    procedure UploadFile(const parameters: RemoteFileInfo); stdcall;
  end;

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


implementation
  uses SysUtils;

function GetITransferService(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ITransferService;
const
  defWSDL = 'http://localhost:1875/TransferService.svc?wsdl';
  defURL  = 'http://localhost:1875/TransferService.svc';
  defSvc  = 'TransferService';
  defPrt  = 'BasicHttpBinding_ITransferService';
var
  RIO: THTTPRIO;
begin
  Result := nil;
  if (Addr = '') then
  begin
    if UseWSDL then
      Addr := defWSDL
    else
      Addr := defURL;
  end;
  if HTTPRIO = nil then
    RIO := THTTPRIO.Create(nil)
  else
    RIO := HTTPRIO;
  try
    Result := (RIO as ITransferService);
    if UseWSDL then
    begin
      RIO.WSDLLocation := Addr;
      RIO.Service := defSvc;
      RIO.Port := defPrt;
    end else
      RIO.URL := Addr;
  finally
    if (Result = nil) and (HTTPRIO = nil) then
      RIO.Free;
  end;
end;


constructor DownloadRequest.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

procedure DownloadRequest.SetFileName(Index: Integer; const AWideString: WideString);
begin
  FFileName := AWideString;
  FFileName_Specified := True;
end;

function DownloadRequest.FileName_Specified(Index: Integer): boolean;
begin
  Result := FFileName_Specified;
end;

constructor RemoteFileInfo.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

initialization
  InvRegistry.RegisterInterface(TypeInfo(ITransferService), 'http://tempuri.org/', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ITransferService), 'http://tempuri.org/ITransferService/%operationName%');
  InvRegistry.RegisterInvokeOptions(TypeInfo(ITransferService), ioDocument);
  InvRegistry.RegisterInvokeOptions(TypeInfo(ITransferService), ioLiteral);
  InvRegistry.RegisterHeaderClass(TypeInfo(ITransferService), FileName, 'FileName', 'http://tempuri.org/');
  InvRegistry.RegisterHeaderClass(TypeInfo(ITransferService), Length, 'Length', 'http://tempuri.org/');
  InvRegistry.RegisterExternalParamName(TypeInfo(ITransferService), 'DownloadFile', 'parameters1', 'parameters');
  RemClassRegistry.RegisterXSInfo(TypeInfo(StreamBody), 'http://schemas.microsoft.com/Message', 'StreamBody');
  RemClassRegistry.RegisterXSClass(DownloadRequest, 'http://tempuri.org/', 'DownloadRequest');
  RemClassRegistry.RegisterSerializeOptions(DownloadRequest, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(RemoteFileInfo, 'http://tempuri.org/', 'RemoteFileInfo');
  RemClassRegistry.RegisterSerializeOptions(RemoteFileInfo, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(FileName, 'http://tempuri.org/', 'FileName');
  RemClassRegistry.RegisterSerializeOptions(FileName, [xoSimpleTypeWrapper]);
  RemClassRegistry.RegisterXSClass(Length, 'http://tempuri.org/', 'Length');
  RemClassRegistry.RegisterSerializeOptions(Length, [xoSimpleTypeWrapper]);

end.
我如何解决这个问题?什么是导致展开错误的原因


以下是wsdl代码:

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" name="TransferService" targetNamespace="http://tempuri.org/">
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://localhost:1875/TransferService.svc?xsd=xsd0" namespace="http://tempuri.org/"/>
<xsd:import schemaLocation="http://localhost:1875/TransferService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
<xsd:import schemaLocation="http://localhost:1875/TransferService.svc?xsd=xsd2" namespace="http://schemas.microsoft.com/Message"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="DownloadRequest">
<wsdl:part name="parameters" element="tns:DownloadRequest"/>
</wsdl:message>
<wsdl:message name="RemoteFileInfo">
<wsdl:part name="parameters" element="tns:RemoteFileInfo"/>
</wsdl:message>
<wsdl:message name="RemoteFileInfo_Headers">
<wsdl:part name="FileName" element="tns:FileName"/>
<wsdl:part name="Length" element="tns:Length"/>
</wsdl:message>
<wsdl:message name="ITransferService_UploadFile_OutputMessage"/>
<wsdl:portType name="ITransferService">
<wsdl:operation name="DownloadFile">
<wsdl:input wsaw:Action="http://tempuri.org/ITransferService/DownloadFile" name="DownloadRequest" message="tns:DownloadRequest"/>
<wsdl:output wsaw:Action="http://tempuri.org/ITransferService/DownloadFileResponse" name="RemoteFileInfo" message="tns:RemoteFileInfo"/>
</wsdl:operation>
<wsdl:operation name="UploadFile">
<wsdl:input wsaw:Action="http://tempuri.org/ITransferService/UploadFile" name="RemoteFileInfo" message="tns:RemoteFileInfo"/>
<wsdl:output wsaw:Action="http://tempuri.org/ITransferService/UploadFileResponse" message="tns:ITransferService_UploadFile_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_ITransferService" type="tns:ITransferService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="DownloadFile">
<soap:operation soapAction="http://tempuri.org/ITransferService/DownloadFile" style="document"/>
<wsdl:input name="DownloadRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="RemoteFileInfo">
<soap:header message="tns:RemoteFileInfo_Headers" part="FileName" use="literal"/>
<soap:header message="tns:RemoteFileInfo_Headers" part="Length" use="literal"/>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="UploadFile">
<soap:operation soapAction="http://tempuri.org/ITransferService/UploadFile" style="document"/>
<wsdl:input name="RemoteFileInfo">
<soap:header message="tns:RemoteFileInfo_Headers" part="FileName" use="literal"/>
<soap:header message="tns:RemoteFileInfo_Headers" part="Length" use="literal"/>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TransferService">
<wsdl:port name="BasicHttpBinding_ITransferService" binding="tns:BasicHttpBinding_ITransferService">
<soap:address location="http://localhost:1875/TransferService.svc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

尝试使您的
与您的
匹配。这解决了我的问题。

您可以尝试另一件事,而不是:

<xsd:import schemaLocation="http://localhost:1875/TransferService.svc?xsd=xsd0" namespace="http://tempuri.org/"/>

使XSD成为本地文件。e、 g.“c:\temp\file0.xsd”

在某些情况下,主要是当http url实际上是https url,或者端口无效时,delphi不会很好地响应重定向,而只是将函数标记为“无法展开”


我理解,如果您正在为其他人创建WSDL,这对您没有帮助,但如果您只是尝试导入WSDL以在delphi中使用,它可能会帮助一些读者。

使用“document/literal wrapped”类型的WDSL时,一个条件是:“输入包装器元素的名称必须与WSDL中的web服务操作名称相同”根据)也许这就是发生的事情。阅读有关WSDL样式的讨论。我已经从服务中添加了WSDL代码。我既不熟悉soap格式,也不知道如何修复c#wsdl…这个问题是否被重新关注?@jandogen-不幸的是,url不再有效。这应该是这样的:“尝试将您的匹配设置为您的,我已经为您解决了这个问题-您需要用反勾号转义xml。有关更多详细信息,请参阅。
<xsd:import schemaLocation="http://localhost:1875/TransferService.svc?xsd=xsd0" namespace="http://tempuri.org/"/>