How to debug SOAP message from matlab

6 vues (au cours des 30 derniers jours)
Tim
Tim le 5 Nov 2011
Hi
I am having issues using a XML WSDL file and using createSoapMessage from matlab to access an online data service.
Using the createSoapMessage function, how can I inspect the soap message that it is creating, so I can debug it?

Réponses (1)

Nigel Davies
Nigel Davies le 15 Août 2012
I have taken this from an answer I put on StackOverflow.
Here is an example of a successful web service query.
msg = createSoapMessage( ...
'http://www.webserviceX.NET', ...
'GetCitiesByCountry', ...
{'Australia'}, {'CountryName'}, ...
{'{http://www.w3.org/2001/XMLSchema}string'}, ...
'document');
response = callSoapService( ...
'http://www.webservicex.net/GlobalWeather.asmx', ...
'http://www.webserviceX.NET/GetCitiesByCountry', msg);
cities = parseSoapResponse(response)
NOTE: The STYLE parameter is 'document', not 'rpc'. The host, www.webservicex.net is very inconsistent in how they capitalize, and it matters, especially where the url is used in the xml.
parseSoapResponse caused me trouble. For the GlobalWeather web service, it returns just the structure containing the requested data. When working with the FedWire service on the same host (see below), parseSoapResponse returns two outputs, a good/bad result and the data.
To query and use the WDSL service, first create a class from the WDSL definition, e.g.:
url = 'http://www.webservicex.net/FedWire.asmx?WSDL';
className = createClassFromWsdl(url);
This will create a directory called @FedWire in the current directory. To explore the services that FedWire offers, you have two options:
dir(@FedWire)
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.
To view the XML msg, use
m.saveXML(m.getFirstChild())
I would also like to know how to view the outgoing and incoming HTTP traffic in MATLAB like you can in a browser. Any ideas?

Catégories

En savoir plus sur Call Web Services from MATLAB Using WSDL dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by