Main Content

Error Handling

Considerations Using Web Services

When creating MATLAB® files that rely on a web service, consider the following:

  • A server issues a time-out error. Repeat the MATLAB command.

  • Internet performance might make your application performance unpredictable.

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

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

  • A server issues other unrecoverable errors.

Error Handling with try/catch Statements

Use the error function in try/catch statements to catch errors that result from method calls or from the matlab.wsdl.createWSDLClient function.

Use a Local Copy of the WSDL Document

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://basemap.nationalmap.gov/arcgis/services/USGSImageryOnly/MapServer?wsdl'];
wsdlFile = 'USGSImageryOnly_MapServer';
if ~exist(wsdlFile,'file') 
    websave(wsdlFile, wsdlURL)
end

Use this strategy when you do not need immediate access to data at the URL.

Java Errors Accessing Service

Once you access a service from MATLAB using the generated client code, you might get Java® errors if:

  • The WSDL for the service changes and you run matlabl.wsdl.createWSDLClient again for the same service in the same MATLAB session.

  • You try to access the service using the regenerated code.

These errors are likely to occur if you modify the service between successive calls to matlabl.wsdl.createWSDLClient.

If you change a service you already accessed or generate the class files in another location, restart MATLAB.

Anonymous Types Not Supported

Anonymous XML types are unnamed types embedded in other types.

For more information, see the IBM® article at “Web services hints and tips: avoid anonymous types”.

See Also

Related Topics

External Websites