Basic SOAP Implementation

Last Updated: 17 Dec 2015

Once a SOAP Server has been installed and configured, available operations will be listed on the Matrix Web Services page of the SOAP Server, as shown in the figure below.

The Matrix Web Services page on the SOAP Server
The Matrix Web Services page of the SOAP Server

Please note that the SOAP Server must be installed under the Web Services folder to view this page. You can access the Web Services page on the Frontend of the SOAP Server.

Request and Response Envelopes

The Web Services page provides sample request and receipt envelopes for each available operation on the SOAP Server.

CreateAsset Sample Request Envelope

Below is a sample SOAP request for the CreateAsset function. Placeholder text is highlighted in blue.

POST http://SYSTEM_ROOT_URL/_web_services/soap-server HTTP/1.1
Host: mysite.comContent-Type: Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://SYSTEM_ROOT_URL/_web_services/soap-server" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ns1:CreateAsset>
      <TypeCode>AssetType</TypeCode>
      <Name>string</Name>
      <ParentID>string</ParentID>
      <LinkType>LinkType</LinkType>
      <LinkValue>string</LinkValue>
      <SortOrder>int</SortOrder>
      <IsDependant>string</IsDependant>
      <IsExclusive>string</IsExclusive>
    </ns1:CreateAsset>
  </soap:Body>
</soap:Envelope>
CreateAsset Sample Response Envelope

Below is a sample SOAP response for the CreateAsset function. Placeholder text is highlighted in blue.

HTTP/1.0 200 OK
Date: Fri, 01 Jan 2010 12:30:34 Australia/Sydney
Server: SYSTEM_ROOT_URL
Content-Type: Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://SYSTEM_ROOT_URL/_web_services/soap-server" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
   <ns1:CreateAssetResponse>
     <NewAssetID>string</NewAssetID>
     <CreateMessage>string</CreateMessage>         
   </ns1:CreateAssetResponse>     
</soap:Body>
</soap:Envelope>

For more information on the CreateAsset operation, refer to the Squiz API Asset Service chapter in this manual.

PHP SOAP Requests

SOAP Server requests can be made in PHP. An example structure for a CreateAsset PHP SOAP request is shown below.

<?php
  ini_set("soap.wsdl_cache_enabled", "0");

  $login = Array(
            'login'    => 'username',
            'password' => 'password',
           );

    try {
     $client = new SoapClient('http://SYSTEM_ROOT_URL/_web_services/server?WSDL', $login); 

     $createInfo = Array (
                    'TypeCode'    => 'folder',
                    'Name'        => 'New Folder',
                    'ParentID'    => '59',
                    'LinkType'    => '1',
                    'IsExclusive' => 'TRUE',
                    'IsDependant' => 'TRUE',
                   );

     $newAsset = $client->CreateAsset($createInfo);
    } catch (SoapFault $e) {
      throw new Exception("SOAP Fault Encountered: ".$e->getMessage());
    }//end
?>

Login details, SOAP client and operation parameters are all provided. This operation will create a Folder asset. For more information on the CreateAsset operation, refer to the Squiz API Asset Servicechapter in this manual.

Javascript API Requests

A Javascript API is available for the SOAP Server, allowing users to configure Frontend SOAP functions using Javascript. Please note that this is not to be confused with the Javascript API asset.

The Javascript library files are found on the server as follows:

  • /__data/asset_types/soap_api/web_services_caller.js 
  • /__data/asset_types/soap_api_asset_service/asset_service_requests.js
  • /__data/asset_types/soap_api_link_service/link_service_requests.js
  • /__data/asset_types/soap_api_metadata_service/metadata_service_requests.js
  • /__data/asset_types/soap_api_design_lookup_service/design_lookup_service_requests.js
  • /__data/asset_types/soap_api_permission_role_service/permission_role_service_requests.js
  • /__data/asset_types/soap_api_search_service/search_service_requests.js
  • /__data/asset_types/soap_api_workflow_service/workflow_service_requests.js
  • /__data/asset_types/soap_api_file_retrieval_service/file_retrieval_service_requests.js

Each of these library files can be included by a Javascript call. For example:

<script type="text/javascript" src="http://SYSTEM_ROOT_URL/__data/asset_types/soap_api/web_services_caller.js"></script> 

<script type="text/javascript"> 

  var current_system_root = 'SYSTEM_ROOT_URL';//(e.g http://yourserver.com);

  include_service_lib('asset', current_system_root); 

</script>

 An example structure for a CreateAsset Javascript SOAP request is shown below.

<script type="text/javascript" src="http://SYSTEM_ROOT_URL/__data/asset_types/soap_api/web_services_caller.js"></script> 

<script type="text/javascript">

  var current_system_root = 'SYSTEM_ROOT_URL';//(e.g http://yourserver.com);

  include_service_lib('asset', current_system_root);

</script>

<script type="text/javascript">
function createPageAsset()
{
  // This is the location of the SOAP Server which support the CreateAsset method
  var location = 'http://SYSTEM_ROOT_URL/_web_services/soap-server';
  var wsdl = 'http://SYSTEM_ROOT_URL/_web_services/soap-server?WSDL'
  var soapBody = CreateAsset('100', 'page_standard', 'NewPage', 1, '', '', '', '');
  var soapRequest = constructSOAPRequest(soapBody, location);
  send(wsdl, soapRequest, 'handleCreatePage');

}//end createPageAsset()

function handleCreatePage(response)
{

}//end handleCreate

</script>

<button onClick="createPageAsset();">Create New Page</button>

This operation will allow the creation of a Standard Page asset. This Javascript SOAP request is used as the content of an asset, such as a Standard Page, creating a button to create a new page, as shown in the figure below.

The Create New Page Button on a Site
A Create New Page button on a Site

When this button is clicked, the SOAP request will be sent and a new page will be created as configured in the Javascript SOAP request.

The Latest

Let Us Know What You Think

Let us know if you spot any errors or if you have any ideas on how we can improve the Matrix Community Website.

Contact Squiz for Demo

Let us show you the true power of Squiz Matrix by giving you a personalised demonstration.