【问题标题】:sending SOAP request with Matlab使用 Matlab 发送 SOAP 请求
【发布时间】:2012-06-27 06:57:11
【问题描述】:

我在发送 Matlab SOAP 请求时遇到了问题 callSoapService(endpoint,soapAction,message)

例如,我如何在http://www.webservicex.net/FedWire.asmx?WSDL 中找到端点、soapAction 和消息

我知道 wsdl 中有多个可能的 soapAction、端点和消息,但我只是在寻找任何 SOAP 请求的示例。

【问题讨论】:

    标签: xml web-services matlab soap webservices-client


    【解决方案1】:

    这是你需要经历的过程。

    首先,根据 WDSL 定义创建一个类:

    url = 'http://www.webservicex.net/FedWire.asmx?WSDL';
    className = createClassFromWsdl(url);
    

    这将在当前目录中创建一个名为@FedWire 的目录。您可以 dir 此目录或使用以下内容来探索 FedWire 提供的服务:

    methods(FedWire)
    

    在您可以使用 Web 服务之前,创建 FedWire 对象的实例:

    fw = FedWire;
    classType = class(fw) % to confirm the class type.
    

    要使用需要城市和州代码的服务,例如 GetParticipantByLocation:

     [Result, FedWireLists] = GetParticipantsByLocation(fw, 'New York', 'NY')
    

    结果应该为真,FedWireLists 是一个包含返回数据的深层嵌套结构。

    打开@FedWire\GetParticipantsByLocation.m 揭示了 MATLAB 生成的代码如何使用 createSoapMessage 和 callSoapService。如果服务不支持 WSDL 查询,则需要使用这些低级函数。

    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'}
    • 风格:“文档”

    并调用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)  
    

    我在使这些示例正常工作时遇到了很多麻烦,因为我将www.webserviceX.NET 之类的服务域名大写,这是我从他们的示例 XML 中提取的。当我改为小写时,它起作用了。

    使用createClassFromWsdl 的示例是对 http://www.mathworks.co.uk/products/bioinfo/examples.html?file=/products/demos/shipping/bioinfo/connectkeggdemo.html

    【讨论】:

    猜你喜欢
    • 2013-08-13
    • 1970-01-01
    • 1970-01-01
    • 2018-05-25
    • 2016-03-25
    • 2017-02-11
    • 2012-08-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多