我在发送 Matlab SOAP 请求时遇到问题 callSoapService(端点,soapAction,消息)<--http://www.mathworks.com/help/techdoc/ref/callsoapservice.html
例如,我如何在 http://www.webservicex.net/FedWire.asmx?WSDL 中找到端点、soapAction 和消息
我知道 wsdl 中有多种可能的soapActions、端点和消息,但我只是在寻找任何 SOAP 请求的示例。
最佳答案
这是您需要经历的过程。
首先,根据 WDSL 定义创建一个类:
url = 'http://www.webservicex.net/FedWire.asmx?WSDL';
className = createClassFromWsdl(url);
这将在当前目录中创建一个名为@FedWire 的目录。您可以指定此目录或使用以下内容来探索 FedWire 提供的服务:
methods(FedWire)
在使用 Web 服务之前,请创建 FedWire 对象的实例:
fw = FedWire;
classType = class(fw) % to confirm the class type.
要使用服务,例如 GetParticipantByLocation,它需要城市和州代码:
[Result, FedWireLists] = GetParticipantsByLocation(fw, 'New York', 'NY')
结果应该为 true,并且 FedWireLists 是包含返回数据的深层嵌套结构。
打开 @FedWire\GetParticipantsByLocation.m 可揭示 MATLAB 生成的代码如何使用 createSoapMessage 和 callSoapService。如果服务不支持 WSDL 查询,则需要使用这些低级函数。
createSoapMessage 的参数填充如下:
- 命名空间:“http://www.webservicex.net/”
- 方法:“GetParticipantsByLocation”
- 值:{'纽约'、'NY'}
- 名称:{'城市'、'州代码'}
- 类型:{'{http://www.w3.org/2001/XMLSchema}字符串'、'{http://www.w3.org/2001/XMLSchema}字符串'}
- 样式:“文档”
并调用SoapService:
- 端点:“http://www.webservicex.net/FedWire.asmx”
- SOAPACTION:“http://www.webservicex.net/GetParticipantsByLocation”
- MESSAGE:createSoapMessage 调用的结果。
以下代码使用低级调用进行相同的查询:
% createSoapMessage(NAMESPACE,METHOD,VALUES,NAMES,TYPES,STYLE) creates a SOAP message.
soapMessage = createSoapMessage( ...
'http://www.webservicex.net/', ...
'GetParticipantsByLocation', ...
{'New York', 'NY'}, ...
{'City', 'StateCode'}, ...
{'{http://www.w3.org/2001/XMLSchema}string', ...
'{http://www.w3.org/2001/XMLSchema}string'}, ...
'document')
% callSoapService(ENDPOINT,SOAPACTION,MESSAGE) sends the MESSAGE,
response = callSoapService( ...
'http://www.webservicex.net/FedWire.asmx', ...
'http://www.webservicex.net/GetParticipantsByLocation', ...
soapMessage);
%parseSoapResponse Convert the response from a SOAP server into MATLAB types.
[result, participants] = parseSoapResponse(response)
我在使这些示例正常工作时遇到了很多麻烦,因为我将服务域名大写,例如从他们的示例 XML 中获取的 www.webserviceX.NET
。当我更改为小写时,它起作用了。
使用createClassFromWsdl
的示例是以下内容的改编
http://www.mathworks.co.uk/products/bioinfo/examples.html?file=/products/demos/shipping/bioinfo/connectkeggdemo.html
关于xml - 使用 Matlab 发送 SOAP 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11220900/