是否可以使用 Delphi 将 XML 发送和接收到 WSDL 函数?

2024-04-16

我们过去曾在 Delphi 中使用 Web 服务,这些服务很简单,参数很少,并向客户端返回单个值。我们工作的新服务应该能够输入 XML 并接收 XML 输出。

有没有可以用于此目的的组件?

当我尝试使用如下所示的方法时,出现错误“SearchAgreements 输入参数 XmlElement 中出现异常 - System.NullReferenceException:对象引用未设置为对象的实例。”

  LDocument := NewXMLDocument;
  <<framed an XML input>>
  DocSearchOut := SearchArgsResponse.Create();
  DoxSerchIn := SearchArgs.Create();
  DoxSerchIn.SOAPTOObject(LDocument.DocumentElement,LDocument.DocumentElement,HTTPRIO1.Converter);
  DoxService := GetIDoxService(True,'',HTTPRIO1);
  DocSearchOut :=DoxService.SearchAgreements(DoxSerchIn)

我什至尝试将 SearchArgs 转换为宽字符串并尝试作为字符串传递。这适用于 HTTPRIO 执行的微小更改。最终编辑

  LDocument := NewXMLDocument;
  <<framed an XML input>>
  DocSearchOut := SearchArgsResponse.Create();
  DoxSerchIn := SearchArgs.Create();
  DoxSerchIn.SearchArgs := LDocument.DocumentElement.XML;
  DoxService := GetIDoxService(True,'',HTTPRIO1);
  DocSearchOut :=DoxService.SearchAgreements(DoxSerchIn)

its wsdl

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 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:i0="http://www.bank.com/dox/service/v1.0.0" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" name="DoxService" targetNamespace="http://tempuri.org/">
<wsdl:import namespace="http://www.bank.com/dox/service/v1.0.0" location="http://devldn.ldn.bank.com:8258/doxManual/DoxService.svc?wsdl=wsdl0"/>
<wsdl:types/>
<wsdl:binding name="BasicHttpBinding_IDoxService" type="i0:IDoxService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SearchAgreements">
<soap:operation soapAction="http://www.bank.com/dox/service/v1.0.0/IDoxService/SearchAgreements" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="DoxService">
<wsdl:port name="BasicHttpBinding_IDoxService" binding="tns:BasicHttpBinding_IDoxService">
<soap:address location="http://devldn.ldn.bank.com:8258/doxManual/DoxService.svc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

wsdl0

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://www.bank.com/dox/service/v1.0.0" 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:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" targetNamespace="http://www.bank.com/dox/service/v1.0.0">
<wsdl:types>
<xsd:schema targetNamespace="http://www.bank.com/dox/service/v1.0.0/Imports">
<xsd:import schemaLocation="http://ldndev.ldn.bank.com:8258/doxManual/DoxService.svc?xsd=xsd0" namespace="http://www.bank.com/dox/service/v1.0.0"/>
<xsd:import schemaLocation="http://ldndev.ldn.bank.com:8258/doxManual/DoxService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="IDoxService_SearchAgreements_InputMessage">
<wsdl:part name="parameters" element="tns:SearchAgreements"/>
</wsdl:message>
<wsdl:message name="IDoxService_SearchAgreements_OutputMessage">
<wsdl:part name="parameters" element="tns:SearchAgreementsResponse"/>
</wsdl:message>
<wsdl:portType name="IDoxService">
<wsdl:operation name="SearchAgreements">
<wsdl:input wsaw:Action="http://www.bank.com/dox/service/v1.0.0/IDoxService/SearchAgreements" message="tns:IDoxService_SearchAgreements_InputMessage"/>
<wsdl:output wsaw:Action="http://www.bank.com/dox/service/v1.0.0/IDoxService/SearchAgreementsResponse" message="tns:IDoxService_SearchAgreements_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>

xsd0

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.bank.com/dox/service/v1.0.0" elementFormDefault="qualified" targetNamespace="http://www.bank.com/dox/service/v1.0.0">
<xs:element name="SearchAgreements">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="searchRequest" nillable="true">
<xs:complexType>
<xs:sequence>
<xs:any minOccurs="0" processContents="lax"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="SearchAgreementsResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="SearchAgreementsResult" nillable="true">
<xs:complexType>
<xs:sequence>
<xs:any minOccurs="0" processContents="lax"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

xsd1

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/">
<xs:element name="anyType" nillable="true" type="xs:anyType"/>
<xs:element name="anyURI" nillable="true" type="xs:anyURI"/>
<xs:element name="base64Binary" nillable="true" type="xs:base64Binary"/>
<xs:element name="boolean" nillable="true" type="xs:boolean"/>
<xs:element name="byte" nillable="true" type="xs:byte"/>
<xs:element name="dateTime" nillable="true" type="xs:dateTime"/>
<xs:element name="decimal" nillable="true" type="xs:decimal"/>
<xs:element name="double" nillable="true" type="xs:double"/>
<xs:element name="float" nillable="true" type="xs:float"/>
<xs:element name="int" nillable="true" type="xs:int"/>
<xs:element name="long" nillable="true" type="xs:long"/>
<xs:element name="QName" nillable="true" type="xs:QName"/>
<xs:element name="short" nillable="true" type="xs:short"/>
<xs:element name="string" nillable="true" type="xs:string"/>
<xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte"/>
<xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt"/>
<xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong"/>
<xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort"/>
<xs:element name="char" nillable="true" type="tns:char"/>
<xs:simpleType name="char">
<xs:restriction base="xs:int"/>
</xs:simpleType>
<xs:element name="duration" nillable="true" type="tns:duration"/>
<xs:simpleType name="duration">
<xs:restriction base="xs:duration">
<xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?"/>
<xs:minInclusive value="-P10675199DT2H48M5.4775808S"/>
<xs:maxInclusive value="P10675199DT2H48M5.4775807S"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="guid" nillable="true" type="tns:guid"/>
<xs:simpleType name="guid">
<xs:restriction base="xs:string">
<xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="FactoryType" type="xs:QName"/>
<xs:attribute name="Id" type="xs:ID"/>
<xs:attribute name="Ref" type="xs:IDREF"/>
</xs:schema>

服务的输入..不幸的是,团队添加了一些东西,因此无法检索 SOAP UI 上的输出。

   <AgreementSearchRequest xmlns="http://www.bank.com/dox/service/v1.0.0" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <Header>
    <PageNo>1</PageNo>
    <PageSize>10</PageSize>
    <Source>IBFD</Source>
  </Header>
  <SearchCriteria>
    <AgreementId>10</AgreementId>
    <AgreementStatus>Search Status</AgreementStatus>
    <AgreementType>Search Type</AgreementType>
    <AgreementVersion>Search Version</AgreementVersion>
    <CompletedDate>2014-05-30T15:56:45.7533005+05:30</CompletedDate>
    <ContractingEntity>Search GCRS Code</ContractingEntity>
    <CounterpartyBranch>Search CP Branch</CounterpartyBranch>
    <CounterpartyEMID>Search CP EMID</CounterpartyEMID>
    <CounterpartyId>Search CP ID</CounterpartyId>
    <CounterpartyName>Search CP Name</CounterpartyName>
    <CounterpartyType>Search CP Type</CounterpartyType>
    <CreditContact>Search Contact</CreditContact>

    <IsOffshoreUser>true</IsOffshoreUser>
    <Products>
      <Product>
        <ProductCode>Search Code</ProductCode>:=
        <ProductName i:nil="true"/>
      </Product>
    </Products>
    <RXM>Search RXM</RXM>
    <RequestedDate>2014-05-30T15:56:45.758183+05:30</RequestedDate>
    <bankLegalEntity>Search LEgal Entity</bankLegalEntity>
    <bankLegalEntityCategory>Search Legal Entity Category</bankLegalEntityCategory>
    <UmbrellaCounterpartyEMID>Search Agent EMID</UmbrellaCounterpartyEMID>
    <UmbrellaCounterpartyName>Search Agent Name</UmbrellaCounterpartyName>
  </SearchCriteria>

我尝试导入 xsd 并替换 xml 文件 HTTPRIO 在执行之前如上所述here.. http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_28281976.html

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://www.bank.com/dox/service/v1.0.0" elementFormDefault="qualified" targetNamespace="http://www.bank.com/dox/service/v1.0.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexType name="ArrayOfProduct">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="Product" nillable="true" type="tns:Product" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="ArrayOfProduct" nillable="true" type="tns:ArrayOfProduct" />
  <xs:complexType name="Product">
    <xs:sequence>
      <xs:element minOccurs="0" name="ProductCode" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="ProductName" nillable="true" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="Product" nillable="true" type="tns:Product" />
    <xs:complexType name="AgreementSearchRequest">
    <xs:sequence>
      <xs:element name="Header" nillable="true" type="tns:AgreementSearchRequestHeader" />
      <xs:element name="SearchCriteria" nillable="true" type="tns:AgreementSearchCriteria" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="AgreementSearchRequest" nillable="true" type="tns:AgreementSearchRequest" />
  <xs:complexType name="AgreementSearchRequestHeader">
    <xs:sequence>
      <xs:element name="PageNo" type="xs:int" />
      <xs:element name="PageSize" type="xs:int" />
      <xs:element name="Source" nillable="true" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="AgreementSearchRequestHeader" nillable="true" type="tns:AgreementSearchRequestHeader" />
  <xs:complexType name="AgreementSearchCriteria">
    <xs:sequence>
      <xs:element minOccurs="0" name="AgreementId" type="xs:int" />
      <xs:element minOccurs="0" name="AgreementStatus" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="AgreementType" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="AgreementVersion" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="CompletedDate" type="xs:dateTime" />
      <xs:element minOccurs="0" name="ContractingEntity" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="CounterpartyBranch" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="CounterpartyEMID" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="CounterpartyId" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="CounterpartyName" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="CounterpartyType" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="CreditContact" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="Products" nillable="true" type="tns:ArrayOfProduct" />
      <xs:element minOccurs="0" name="RXM" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="RequestedDate" type="xs:dateTime" />
      <xs:element minOccurs="0" name="egalEntity" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="LegalEntityCategory" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="UmbrellaCounterpartyEMID" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="UmbrellaCounterpartyName" nillable="true" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="AgreementSearchCriteria" nillable="true" type="tns:AgreementSearchCriteria" />
</xs:schema>

有的是网络服务工具包 http://wiki.lazarus.freepascal.org/Web_Service_Toolkit.

它有一个代码生成器,它采用 wsdl 并从中生成与 Web 服务交互的 Pascal 类。

似乎正是你所需要的,但我不知道具体情况。


然后还有我的互联网工具 http://www.benibela.de/documentation/internettools/适用于 FreePascal(不是 Delphi)。

它们包含 XQuery 的解释器,XQuery 是一种通用 XML 处理语言,因此您可以将它与所有可能的基于 XML/HTML 的 API 一起使用,而代码比使用 DOM 方法少得多。但它不会帮助您处理任何 WSDL 特定的内容,您需要自己为每个请求编写 XML。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

是否可以使用 Delphi 将 XML 发送和接收到 WSDL 函数? 的相关文章

  • 如何将FireMonkey表单无缝嵌入VCL表单中?

    我使用了中描述的技巧这个问题 https stackoverflow com questions 7315050 delphi xe2 possible to instantiate a firemonkey form in vcl app
  • Delphi 的免费加密库 [关闭]

    Closed 此问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我正在为 Delphi 2010 寻找一个免费且最新的加密库 该库实现 RSA 和 AES Rijnda
  • 在 Spring 中设置 WS https 调用超时 (HttpsUrlConnectionMessageSender)

    我正在尝试为 WS 调用设置超时 我延长了WebServiceGatewaySupport并尝试将发送者超时设置为如下 public Object marshalSendAndReceive Object requestPayload We
  • 如何从对Web服务发出的请求中获取客户端IP地址

    我的 IIS 中托管有一个 Web 服务 当客户端直接使用我的服务时 我需要找出客户端 IP 地址 like http MyIpAddress MyApplication MyWebServiceClass asmx http MyIpAd
  • PHP Soap Server:使用字符串(xml 字符串)而不是 WSDL 文件(指向它的 url)实例化

    Soap Server的PHP页面 我见过 http www php net manual en soapserver soapserver php http www php net manual en soapserver soapser
  • Silverlight WCF服务跨域问题

    我有一个 silverlight 应用程序 托管在 Intranet mydomain net 和一个 WCF 服务 webservices mydomain net 我需要跨站点策略文件吗 如果是这样 只允许从 Intranet mydo
  • Delphi如何使用其他窗体中的类型?

    抱歉 这是一个非常新手的问题 我正在对这个庞大的应用程序进行维护 它有5种不同的形式 我们将全局变量放在一个单元 uGlobal 中 但我似乎无法从数据单元 uData 访问它 我有这个 Unit uGlobal type TmyType
  • 如何读取注册表项的默认值

    我有一个 Delphi XE2 项目来使用注册表项进行某些操作 所以我定义了以下代码 procedure TMainForm BitBtn01Click Sender TObject var RegistryEntry TRegistry
  • 检测反射 DLL 注入

    在过去的几年中 恶意软件 以及一些渗透测试工具 如 Metasploit 的 meterpreter 负载 已经开始使用反射 DLL 注入 PDF http www harmonysecurity com files HS P005 Ref
  • 如何追踪手柄泄漏?

    在我的一个应用程序中 我观察到句柄数量不断增加 在不使用应用程序的情况下 该数字大约每秒增加一次 因此后台处理代码的某些部分一定存在句柄泄漏 我如何追踪此类泄漏 有什么工具可以帮助解决这个问题吗 跟踪句柄泄漏时要寻找哪些模式 导致手柄泄漏的
  • 以 png 格式剪辑幻灯片 (Delphi 2010)

    I have a filmstrip of images in png format like this 我想知道如何剪辑每个图像并将这些图像放入 TImageList 控件中 并始终保留透明度 EDIT 是的 在设计时 RRUZ 提到的技
  • 如何将值从 android 传递到 php Web 服务并检索它?

    我正在尝试将一个值传递给我的 php web 服务 我已经使用此代码来传递 名称 值 private class MyAsyncTask extends AsyncTask
  • 为什么将 SOAP 用于 Web 服务?

    我读过教程 web service php mysql xml json http davidwalsh name web service php mysql xml json 看来一切都好 但是为什么我们应该使用soap 来提供网络服务呢
  • 如何构建 Perl Web 服务基础设施

    我有许多用于管理多服务器基础设施的脚本 其中一些脚本需要 root 访问权限 一些需要访问数据库 并且大多数脚本都是基于 perl 的 我想将所有这些脚本转换为非常简单的 Web 服务 可以从不同的应用程序执行 这些 Web 服务将接受常规
  • App.Config 和 Web.Config 之间的区别?

    当在 wpf 中构建桌面应用程序时 您可以阅读问题文档并在人们的答案引用 web config 时安全地替换 app config 吗 如果是这样 您是否需要注意任何明显的陷阱 tnx 阅读文档 http msdn microsoft co
  • Delphi 流畅的界面

    使用上有什么优点和缺点流畅的界面 http en wikipedia org wiki Fluent interface在德尔福 流畅的界面应该会增加可读性 但我对此有点怀疑one包含很多链式方法的长 LOC 是否存在编译器问题 是否存在任
  • Delphi:写入后代类中私有祖先的字段

    我需要修复第三方组件 该组件的类具有私有变量 该变量由其后代主动使用 TThirdPartyComponentBase class private FSomeVar Integer public end TThirdPartyCompone
  • 轻松的反应

    我有一个与这里描述的类似的案例 动态更改RESTEasy服务返回类型 https stackoverflow com questions 3786781 dynamically change resteasy service return
  • 如何使用 FieldDefs 在运行时创建新的 SQLite 文件和表?

    我正在使用 Delphi Seattle 在全新的 SQLite 文件中创建一个全新的表 并且仅使用 FieldDefs 和非可视代码 我可以使用 ExecSQL CREATE TABLE 语法创建一个表 但不能如下所示 我得到 没有这样的
  • Axis2 错误:要输出的文本中的空白字符 (0x4) 无效

    我创建了一个 Java 客户端 使用 Axis2 1 7 6 作为代码生成器与 SOAP Web 服务进行交互 问题在于客户端的某些输入抛出异常并显示以下消息 org apache axis2 AxisFault Invalid white

随机推荐