Documentation Center

  • Trial Software
  • Product Updates

Considerations When Using Web Services

XML-MATLAB Data Type Conversion Used in Web Services

MATLAB® SOAP functions automatically convert XML data types used in SOAP messages to MATLAB types (classes), and vice-versa. The following table contains the XML type and the corresponding MATLAB type.

XML Data TypeMATLAB Type (Class) 

string

char array

boolean

logical scalar

decimal

double scalar

float

double scalar

double

double scalar

duration

double scalar

time

double scalar

date

double scalar

gYearMonth

char array

gYear

char array

gMonthDay

char array

hexbinary

double array

base64Binary

double array

anyURI

char array

QName

char array

Programming with Web Services

When creating MATLAB files that rely on Web services, consider the following:

  • If the Web service you want to use is on the Internet, your application performance could be unpredictable because it depends in part on Internet performance.

  • Conventions and established procedures for Web services and related technologies, like WSDL and SOAP, are still evolving. You could find inconsistencies or unexpected behavior when using Web services.

  • A Web service could change over time, which can impact its usage and results in MATLAB.

Use common program control and error-handling routines to minimize the risks, such as:

  • Use try/catch statements to catch errors that result from method calls or from the createClassFromWsdl function.

  • Use If statements to determine if expressions or statements are true or false. For example, if you have a valid URL for a WSDL document, you can determine whether or not you have a local copy of the WSDL document. If you do not, you can achieve better performance if you create a local copy and use the local copy instead of the version at the URL:

    wsdlUrl = ['http://www.xmethods.net/sd/2001' ...
               '/CurrencyExchangeService.wsdl'];
    wsdlFile = 'CurrencyExchangeService.wsdl';

    the following if statement stores the WSDL locally, if it does not already exist:

    if ~(exist(wsdlFile,'file') == 2)
        urlwrite(wsdlUrl,wsdlFile);
    end
    
  • Use error functions to report specific errors. The following example shows an error function used in an try/catch statement:

    try
    	students = studentNames(obj);
    catch
    	error('Could not return name.');
    end
    

For more information about program control and error-handling statements, see Exception Handling in a MATLAB Application.

Was this topic helpful?