Skip to main content

Defining a One-Way Web Method

For an InterSystems IRIS® data platform web service, normally, when you execute a web method, a SOAP message is returned, even if the method has no return type and returns nothing. This SOAP response message has the following general form:

<?xml version="1.0" encoding="UTF-8" ?>
<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>
   <MethodNameResponse xmlns="http://www.myapp.org"></MethodNameResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

In rare cases, you might need to define a web method as being one-way. Such a method must return no value, and no SOAP response is expected to the request message. To define a one-way web method, define the return type of the method as %SOAP.OneWayOpens in a new tab. In this case:

  • The WSDL does not define output defined for this web method.

  • The web service does not return a SOAP message (unless the service adds a header element; see the subsection). That is, the HTTP response message does not include any XML content.

Note:

One-way methods should normally not be used. A request-response pair is much more common, supported, and expected — even for a method that has no return type.

See WSDL Differences for One-Way Web Methods.

One-Way Web Methods and SOAP Headers

If the web method adds a header element, then the HTTP response does include XML content as follows:

<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' ...
  <SOAP-ENV:Header>
     header elements as set by the web service
 </SOAP-ENV:Header>
  <SOAP-ENV:Body></SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Dynamically Making a Web Method One Way

You can also dynamically redefine a web method to be one way. To do so, invoke the ReturnOneWay() of the web service within the definition of the web method. For example:

Method HelloWorldDynamic(oneway as %Boolean = 0) As %String [ WebMethod ]
{
  If oneway {Do ..ReturnOneWay() }
  Quit "Hello world "
}

If the argument is 0, this web method returns a SOAP response whose body contains Hello world. If the argument is 1, this method does not return a SOAP response.

FeedbackOpens in a new tab