web-services - Delphi SOAP 请求
问题描述
我正在尝试向 Delphi XE5 中的 Web 服务发送 SOAP 请求。实际上,我通过 WSDL Importer 导入了一个可用的 WSDL。我使用组件 THTTPRIO (rio) 和 IdEncoderMIME1 为 HTTP 身份验证请求建立了与此 Web 服务的连接。
SOAP 请求是通过 TXMLDocument 构建的,具有以下结构:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cod=NS_Codelist>
<soapenv:Header/>
<soapenv:Body>
<cod:GetLatestChangeDatesRequest>
<!--Zero or more repetitions:-->
<CodeListID>1035</CodeListID>
</cod:GetLatestChangeDatesRequest>
</soapenv:Body>
</soapenv:Envelope>
此外,我收到了网络服务的端口类型。
codeserv:= GetCodeListPortType(true,'',rio);
这些是来自 WSDL 的方法:
codeserv.GetLatestChangeDates(const body:GetLatestChangeDatesRequestType):GetLatestChangeDatesResponseType
GetLatestChangeDatesRequestType = array of Int64;
GetLatestChangeDatesRequest = GetLatestChangeDatesRequestType;
GetLatestChangeDatesResponseType = array of CodeListLatestChangeDateType;
GetLatestChangeDatesResponse = GetLatestChangeDatesResponseType;
CodeListLatestChangeDateType
property CodeListID: Int64
property LatestChangeDate: TXSDate
我已经尝试为参数设置一个 Int64 数组,但随后显示“缺少元素 CodeListID”。
不幸的是,我找不到将此 XML SOAP 请求发送到 web 服务并接收响应的方法。有任何想法吗?
编辑:我尝试使用 WSDL 方法
var
codeserv: CodeListPortType;
arrIDs: GetLatestChangeDatesRequest;
response: GetLatestChangeDatesResponse;
begin
codeserv:= GetCodeListPortType(true,'',rio);
SetLength(arrIDs,1);
arrIDs[0]:= 1035;
response:= codeserv.GetLatestChangeDates(arrIDs);
但随后我收到以下错误消息:'发现以元素'long'开头的无效内容。需要“{CodeListID}”之一。在 SOAP 请求中必须有元素 CodeListID。不幸的是,GetLatestChangeDates 方法似乎没有在 SOAP 请求中创建元素。上面发布的 SOAP 请求应该是用这种方法创建的(希望如此)。
解决方案
推荐阅读
- list - 如何获取整数列表?
- bash - 从多个文件中检索带有模式的行
- java - 如何使用 typedQuery 在 Criteria api 上添加分页?
- sql-server - 使用唯一键创建视图并按多个参数分组
- java - 有没有一种方法可以优化使用 java 流在 Map 中查找元素?
- javascript - 如何修复按手机上的后退按钮后不返回启动画面
- go - 重新插入通道导致死锁
- android - 在 Android Studio 中每 10 秒显示一次位置
- deep-learning - 使用 I3D pytorch 实现提取视频的帧特征
- javascript - Javascript 代码在 ios 和 Safari 中不起作用