SOAP Faults

Sepasoft MES Module Suite

SOAP Faults

SOAP Faults are supported by the Web Services module.

Example SOAP Fault

SOAP Faults are returned in industry-standard XML format. Example:

Example SOAP Fault

<?xml version="1.0"?>
<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>
    <soapenv:Fault>
      <faultcode>soapenv:Server.userException</faultcode>
      <faultstring>com.inductiveautomation.ignition.licensing.common.LicensingException: CDKey '4G9BM9' not found</faultstring>
      <detail>
        <ns1:fault xmlns:ns1="http://webservices.inductiveautomation.com">
          <ns1:responseCode>
            <ns1:code>5</ns1:code>
            <ns1:desc>Rejected CDKey</ns1:desc>
          </ns1:responseCode>
        </ns1:fault>
        <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">ip-10-232-151-57.us-west-1.compute.internal</ns2:hostname>
      </detail>
    </soapenv:Fault>
  </soapenv:Body>
</soapenv:Envelope>

Example SOAP Fault Implementation

The following example steps demonstrate implementing a simple SOAP fault script in the Sepasoft Web Services module:

  • Create a new SOAP Provider in the MES Web Services module (in the Project section of Ignition Designer).
  • Add a new Operation named "fault_test".
  • In Types under "fault_test", add a new member named "user_input" of type Integer.
  • In Types under "fault_testResponse" add new member named "out" of type String.

In the Script area, paste the following:

XML
# SOAP Output Header
output_header = None
	
# HTTP Response Headers
http_response_headers = {}
	
if user_input >= 5:
	# returned fault must be of dictonary type containing "faultString" as a key. 
	# key "details" is optional
	# if any other keys, exception will be thrown
	fault_dict = {
			'faultString': "Bad User Input",
			'detail': {
				'responseCode': {
					'code': 1,
					'desc': '"user_input", %d, not valid. "user_input" must be less than 5'
				}
			}
		}
		
	# Note: Returning "fault" instead of body	
	return {'header': output_header, 'fault':fault_dict, 'http_headers': http_response_headers}
		
else:
	output_body = {
			'fault_testResponse': {
				'out': "No fault: passed value: %d" % user_input
			}
		}
	return {'header': output_header, 'body': output_body, 'http_headers': http_response_headers}

This script takes an integer input. If the input is less than 5, it successfully returns. If it is greater than or equal to 5, it raises a fault.

  • Save your new SOAP Provider.
  • Create a new SOAP Consumer in the MES Web Services module (in the Project section of Ignition Designer).
  • Copy the WSDL URL from the SOAP Provider to the SOAP Consumer.
  • Copy the script and set "user_input" to 4. 
  • Execute the script. It should return a dictionary.
  • Change "user_input" to 5.
  • Execute the script. It should throw an exception with your faultString message in the exception body.

Sepasoft MES Module Suite