问题描述
我在发送Matlab SOAP请求时遇到了麻烦callSoapService(endpoint,soapAction,message)< --http://www.mathworks.com/help/techdoc/ref/callsoapservice.html
I've been having trouble sending Matlab SOAP requestcallSoapService(endpoint,soapAction,message) <--http://www.mathworks.com/help/techdoc/ref/callsoapservice.html
例如,我如何在 http://www中找到端点,soapAction和消息. webservicex.net/FedWire.asmx?WSDL
我知道wsdl中有多个可能的soapActions,端点和消息,但我只是在寻找任何SOAP请求的示例.
I understand that there are multiple possible soapActions, endpoints, and messages in a wsdl but I was just looking for an example of any SOAP request.
推荐答案
这是您需要经历的过程.
This is the process you need to go through.
首先,根据WDSL定义创建一个类:
First, create a class from the WDSL definition:
url = 'http://www.webservicex.net/FedWire.asmx?WSDL';
className = createClassFromWsdl(url);
这将在当前目录中创建一个名为@FedWire的目录.您可以在此目录下创建目录,或使用以下内容探索FedWire提供的服务:
This will create a directory called @FedWire in the current directory. You can dir this directory or use the following to explore the services that FedWire offers:
methods(FedWire)
在使用Web服务之前,请创建FedWire对象的实例:
Before you can use the web service, create an instance of the FedWire object:
fw = FedWire;
classType = class(fw) % to confirm the class type.
要使用服务,例如GetParticipantByLocation,它需要输入City和StateCode:
To use a service, for example, GetParticipantByLocation, which requires a City and StateCode:
[Result, FedWireLists] = GetParticipantsByLocation(fw, 'New York', 'NY')
结果应为true,并且FedWireLists是一个深度嵌套的结构,其中包含返回的数据.
Result should be true and FedWireLists is a deeply nested structure containing the data returned.
打开@FedWire \ GetParticipantsByLocation.m揭示了MATLAB生成的代码如何使用createSoapMessage和callSoapService.如果该服务不支持WSDL查询,则必须使用这些低级功能.
Opening @FedWire\GetParticipantsByLocation.m reveals how the MATLAB generated code is using createSoapMessage and callSoapService. If the service does not support WSDL queries, then using these low level functions becomes necessary.
createSoapMessage的参数是这样填充的:
The parameters for createSoapMessage are populated like this:
- NAMESPACE:"http://www.webservicex.net/"
- 方法:"GetParticipantsByLocation"
- 值:{'New York','NY'}
- 名称:{'City','StateCode'}
- 类型:{'{http://www.w3.org/2001/XMLSchema}字符串','{http://www.w3.org/2001/XMLSchema}字符串'}
- 样式:文档"
和callSoapService:
and callSoapService:
- ENDPOINT:"http://www.webservicex.net/FedWire.asmx"
- SOAPACTION:"http://www.webservicex.net/GetParticipantsByLocation"
- 消息:createSoapMessage调用的结果.
以下代码对低级调用进行相同的查询:
The following code makes the same query with the low level calls:
% 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)
使这些示例正常工作很麻烦,因为我要大写这样的服务域名,例如www.webserviceX.NET
,这是从示例XML中获取的.当我更改为小写字母时,它起作用了.
I had a lot of trouble making these examples work because I was capitalizing the service domain name like this www.webserviceX.NET
which I took from their example XML. When I changed to lowercase, it worked.
使用createClassFromWsdl
的示例是对 http://www.mathworks.co.uk/products/bioinfo/examples.html?file=/products/demos/shipping/bioinfo/connectkeggdemo.html
这篇关于用Matlab发送SOAP请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!