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.
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