sending SOAP request with Matlab

时光毁灭记忆、已成空白 提交于 2019-12-13 16:33:45

问题


I've been having trouble sending Matlab SOAP request callSoapService(endpoint,soapAction,message) <--http://www.mathworks.com/help/techdoc/ref/callsoapservice.html

For instance how would I find the endpoint, soapAction, and message in http://www.webservicex.net/FedWire.asmx?WSDL

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.


回答1:


This is the process you need to go through.

First, create a class from the WDSL definition:

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

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)

Before you can use the web service, create an instance of the FedWire object:

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

To use a service, for example, GetParticipantByLocation, which requires a City and StateCode:

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

Result should be true and FedWireLists is a deeply nested structure containing the data returned.

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.

The parameters for createSoapMessage are populated like this:

  • NAMESPACE: 'http://www.webservicex.net/'
  • METHOD: 'GetParticipantsByLocation'
  • VALUES: {'New York', 'NY'}
  • NAMES: {'City', 'StateCode'}
  • TYPES: {'{http://www.w3.org/2001/XMLSchema}string', '{http://www.w3.org/2001/XMLSchema}string'}
  • STYLE: 'document'

and callSoapService:

  • ENDPOINT: 'http://www.webservicex.net/FedWire.asmx'
  • SOAPACTION: 'http://www.webservicex.net/GetParticipantsByLocation'
  • MESSAGE: the result of the createSoapMessage call.

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)  

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.

The example using createClassFromWsdl is an adaptation of http://www.mathworks.co.uk/products/bioinfo/examples.html?file=/products/demos/shipping/bioinfo/connectkeggdemo.html



来源:https://stackoverflow.com/questions/11220900/sending-soap-request-with-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!