Receive an XML with ACTION with mustUnderstand=1
Hi, guys, I need some help, I'm getting an XML from the Matrix application and in the header there's an Action that has the property mustUndertand = 1
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://protocolomatrix.matrixsaude.com/RecebeResultado</Action>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
No BS Receives but cannot handle the action.
.png)
Comments
The problem is that the incoming SOAP header contains an Action element marked with mustUnderstand="1". A header with mustUnderstand=1 is mandatory, so the receiver must recognize and support it before processing the message. If it does not, InterSystems rejects the message with a SOAP fault and ignores it. [1]
If a given header element specifies mustUnderstand=1, the element is considered mandatory, and the recipient must support it. The recipient cannot process the message unless it recognizes all mandatory header element. [1]
Following the SOAP standard, InterSystems IRIS rejects SOAP messages that contain required but unsupported header elements. Specifically, if InterSystems IRIS web service or client receives a message that contains a header element that includes mustUnderstand=1, and if that service or client does not support that header element, the service or client issues a SOAP fault and then ignores the message. [1]
To handle this, you need to make your service support that header element. If you generated the service/client from the WSDL, InterSystems can generate classes for the header elements automatically. If you created the service manually, you must define the header yourself as a subclass of %SOAP.Header, giving its namespace and XML name, and then declare it as a supported header. [1]
The needed definition pattern is:
- Create a subclass of
%SOAP.Header. - Set
NAMESPACEto the header namespace. - Set
XMLNAMEto the header element name. - Add properties for the header content you need.
- Optionally set
XMLFORMAT. [1]
For your specific header, the relevant values from the XML are:
- Header name:
Action - Namespace:
http://schemas.microsoft.com/ws/2005/05/addressing/none[2]
Also, the WSDL should advertise supported header elements. If SOAP headers are added manually, they should be declared in XData, and the web service class should specify USECLASSNAMESPACES = 1; otherwise, the generated WSDL may not include the needed header information. [1]
If you need to return or detect this specific condition as a SOAP fault, the standard fault macro for this case is $$$FAULTMustUnderstand, used when the web service receives an unexpected element marked with mustUnderstand="true". [3]
Sources: