createSoapMessage

Create SOAP (Simple Object Access Protocol) message to send to server

createSoapMessage will be removed in a future release. Use matlab.wsdl.createWSDLClient instead.

Syntax

  • message = createSoapMessage(namespace,method,values,names,types) example
  • message = createSoapMessage(namespace,method,values,names,types,style)

Description

example

message = createSoapMessage(namespace,method,values,names,types) creates a SOAP message.

message = createSoapMessage(namespace,method,values,names,types,style) creates message with specified style.

Examples

expand all

Retrieve Book Information from Library Database

This example assumes the library is on a local intranet and does not use an actual endpoint; therefore, you cannot run it.

Retrieve the name of the author of a book titled "In the Fall." The relative path of the library service is urn:LibraryCatalog. To get the author's name, use the getAuthor function, which takes the book name as the input value. The getAuthor parameter is nameToLookUp. The XML data type for title is {http://www.w3.org/2001/XMLSchema}string. The SOAP message style is rpc by default.

Create the SOAP message.

message = createSoapMessage(...
  'urn:LibraryCatalog',...
  'getAuthor',...
  {'In the Fall'},...
  {'nameToLookUp'},...
  {'{http://www.w3.org/2001/XMLSchema}string'})
message =
 
[#document: null]

This response does not necessarily indicate that the message is valid, although certain input problems produce error messages.

Send the message to the server for processing, and get the author's name back. The server endpoint is http://test/soap/services/LibraryCatalog. The server method is urn:LibraryCatalog#getAuthor.

response = callSoapService(...
  'http://test/soap/services/LibraryCatalog',...
  'urn:LibraryCatalog#getAuthor',...
  message)
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getAuthorResponse xmlns="urn:LibraryCatalog">
<ns1:getAuthorReturn xmlns:ns1="http://latestversion.soap.test">
Kate Alvin
</ns1:getAuthorReturn>
</getAuthorResponse>
</soapenv:Body>
</soapenv:Envelope>

MATLAB® returns the message in a single line, displayed here on separate lines for legibility.

Extract the author's name.

author = parseSoapResponse(response)
author = Kate Alvin

MATLAB automatically converted the XML string data type to char.

Input Arguments

expand all

namespace — Location of Web servicestring

Location of Web service, specified as a string in the form of a valid Uniform Resource Identifier (URI).

Example: 'urn:LibraryCatalog'

method — Name of Web service operationstring

Name of Web service operation, specified as a string.

Example: 'getAuthor'

values — Input arguments for methodcell array

Input arguments for method, specified as a cell array.

Example: {'In the Fall'}

names — Parameter for methodcell array

Parameter for method, specified as a cell array.

Example: {'nameToLookUp'}

types — XML data types for valuescell array

XML data types for values, specified as a cell array.

Example: {'{http://www.w3.org/2001/XMLSchema}string'}

style — Style for structuring SOAP message'rpc' (default) | 'document'

Style for structuring the SOAP message, specified as one of these values. Use a style supported by the service specified in namespace.

'rpc'

Remote Procedure Call (RPC) encoding

'document'

Document-style encoding

Output Arguments

expand all

message — Java® document object model (DOM)string

Java document object model (DOM), returned as a string. Use message as input to callSoapService function.

Was this topic helpful?