Skip to main content

Testing SOAP Fault Generation

You can use the Terminal to test the SOAP Fault generation code that you added to SOAPTutorial.SOAPService. Simply invoke GetContact and pass it an invalid ID value.

  1. Open the Terminal. Use the ZN command to switch to the namespace in which you have installed the sample application.

  2. Create an instance of the service class and invoke its GetContact, passing it an invalid ID value.

    
    USER>Set service = ##class(SOAPTutorial.SOAPService).%New()
    USER>Do service.GetContact(0)
    
    
  3. The method returns a SOAP Fault that looks something like this

    
    <?xml version='1.0' encoding='UTF-8' standalone='no' ?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
    xmlns:s='http://www.w3.org/2001/XMLSchema' >
      <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
          <faultcode>SOAP-ENV:ContactNotFound</faultcode>
          <faultstring>application error</faultstring>
          <detail>Contact with id 0 could not be found!</detail>
        </SOAP-ENV:Fault>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    
FeedbackOpens in a new tab