Question
· Jan 29

Handling/Removing Unexpected Top-Level XML Tag in SOAP Response

Hello,

First of all thanks for your help reading and answering this question, and thanks for your time.

We have been investigating how to handle the following need:

Our client which has the system which reveices our ESB's responses needs a SOAP response as follows, where all the ACK is inside a top XML tag called <ACK>:

<?xml version="1.0" encoding="UTF-8"?><ACK xmlns="urn:hl7-org:v2xml">
    <MSH>
        <MSH.1>|</MSH.1>
        <MSH.2>^~\&amp;</MSH.2>
        <MSH.3>
            <HD.1>sistemaExterno</HD.1>
        </MSH.3>
        <MSH.4>
            <HD.1>scs</HD.1>
            <HD.2>350290</HD.2>
        </MSH.4>
        <MSH.5>
            <HD.1>EXTERNAL</HD.1>
        </MSH.5>
        <MSH.6>
            <HD.1>EXTHL7</HD.1>
        </MSH.6>
        <MSH.7>
            <TS.1>20240129114103</TS.1>
        </MSH.7>
        <MSH.9>
            <MSG.1>ACK</MSG.1>
        </MSH.9>
        <MSH.10>70596007</MSH.10>
        <MSH.11>
            <PT.1>P</PT.1>
        </MSH.11>
        <MSH.12>
            <VID.1>2.5</VID.1>
        </MSH.12>
        <MSH.13>1</MSH.13>
        <MSH.15>AL</MSH.15>
        <MSH.16>AL</MSH.16>
        <MSH.18>ASCII</MSH.18>
    </MSH>
    <MSA>
        <MSA.1>AE</MSA.1>
        <MSA.2>70596007</MSA.2>
        <MSA.3>3</MSA.3>
    </MSA>
    <ERR>
        <ERR.1>
            <ELD.4>
                <CE.2>PETICION_PRUEBAS</CE.2>
            </ELD.4>
        </ERR.1>
    </ERR>
</ACK>

We have developed the SOAP Web Service, however it always responds with an additional XML top level tag which is "<ProcesarPeticionResult>":

<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>
      <ACK xmlns="urn:hl7-org:v2xml">
         <ProcesarPeticionResult>
            <MSH>
               <MSH.1>|</MSH.1>
               <MSH.2>^~\&amp;</MSH.2>
               <MSH.3>
                  <HD.1>sistemaExterno</HD.1>
               </MSH.3>
               <MSH.4>
                  <HD.1>scs</HD.1>
                  <HD.2>350290</HD.2>
               </MSH.4>
               <MSH.5>
                  <HD.1>HGF</HD.1>
               </MSH.5>
               <MSH.6>
                  <HD.1>EXTHL7</HD.1>
               </MSH.6>
               <MSH.7>
                  <TS.1>20240129135144</TS.1>
               </MSH.7>
               <MSH.9>
                  <MSG.1>ACK</MSG.1>
               </MSH.9>
               <MSH.10>70589905</MSH.10>
               <MSH.11>
                  <PT.1>P</PT.1>
               </MSH.11>
               <MSH.12>
                  <VID.1>2.5</VID.1>
               </MSH.12>
               <MSH.13>1</MSH.13>
               <MSH.15>AL</MSH.15>
               <MSH.16>AL</MSH.16>
               <MSH.18>ASCII</MSH.18>
            </MSH>
            <MSA>
               <MSA.1>AA</MSA.1>
            </MSA>
         </ProcesarPeticionResult>
      </ACK>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

We think that the tag "<ProcesarPeticionResult>" is generated by default because the SOAP Service's Web Method which receives the request and emits the response is called "ProcesarPeticion.

 

Is there any way to remove the unexpected tag "<ProcesarPeticionResult>"?

Is there any configuration, parameter or property which we could add to the SOAP Service or to the Ens.Response Message to get rid of the unexpected tag?

 

The SOAP's Service code is:

Class Servicios.Peticiones.Derivaciones.Gestionv01r00 Extends EnsLib.SOAP.Service [ ClassType = "", Inheritance = right, ProcedureBlock ]
{

Parameter ADAPTER = "EnsLib.SOAP.InboundAdapter";
/// Nombre del WebService.
Parameter SERVICENAME = "Gestion";
/// Namespace SOAP para el Servicio Web
Parameter NAMESPACE = "urn:hl7-org:v2xml";
/// Se utilizarán namespaces de clases referenciadas en WSDL.
Parameter USECLASSNAMESPACES = 1;
Method ProcesarPeticion(MSH As hl7.MSH.CONTENT, NTE As hl7.NTE.CONTENT, ORMO01PATIENT As hl7.ORMO01.PATIENT.CONTENT(XMLNAME="ORM_O01.PATIENT"), ORMO01ORDER As hl7.ORMO01.ORDER.CONTENT(XMLNAME="ORM_O01.ORDER"), SFT As hl7.SFT.CONTENT, MSA As hl7.MSA.CONTENT, ERR As hl7.ERR.CONTENT) As Mensajes.Response.Peticiones.Derivaciones.EnvioPeticiones.operacionResponse [ Final, ProcedureBlock = 1, SoapAction = "http://FUERTEVENTURA.Servicios/Asentimientos/ProcesarACK", SoapBindingStyle = document, SoapBodyUse = literal, SoapMessageName = ACK, SoapRequestMessage = ORM_O01, WebMethod ]
{
	set request = ##class(Mensajes.Request.Peticiones.Derivaciones.EnvioPeticiones.operacionRequest).%New()
	set request.MSH = MSH
	do request.NTE.Insert(NTE)
	set request.ORMO01PATIENT = ORMO01PATIENT
	do request.ORMO01ORDER.Insert(ORMO01ORDER)
	
	set tSC = ..SendRequestSync("EnrutadorGestionDerivaciones",request,.response)
	quit response
}

Method OnProcessInput(pInput As EnsLib.HL7.Message) As %Status
{
   Quit ..SendRequestAsync("EnrutadorGestionDerivaciones",pInput)
}

}

In addition the Ens.Response code is as we could inspect here:

Class Mensajes.Response.Peticiones.Derivaciones.EnvioPeticiones.operacionResponse Extends Ens.Response [ ProcedureBlock ]
{
Property MSH As hl7.MSH.CONTENT;
Property SFT As list Of hl7.SFT.CONTENT;
Property MSA As hl7.MSA.CONTENT;
Property ERR As list Of hl7.ERR.CONTENT;

 

Please, could you help us with this need, please?

 

Thanks for your time, help, and replies.

 

Besides we have also read:

https://community.intersystems.com/post/debugging-soap-web-client

https://community.intersystems.com/post/there-way-automatically-remove-s...

https://docs.intersystems.com/irisforhealthlatest/csp/documatic/%25CSP.D...

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...

 

Thanks for your help and time. ☯️

Product version: IRIS 2020.1
Discussion (3)2
Log in or sign up to continue

We have tried to solve this issue ourselves as follows:

We have changed the method's output parameter, from an Ens.Response to an %XML.String(MAXLEN=""):

Before:

Method ProcesarPeticion(MSH As hl7.MSH.CONTENT, NTE As hl7.NTE.CONTENT, ORMO01PATIENT As hl7.ORMO01.PATIENT.CONTENT(XMLNAME="ORM_O01.PATIENT"), ORMO01ORDER As hl7.ORMO01.ORDER.CONTENT(XMLNAME="ORM_O01.ORDER"), SFT As hl7.SFT.CONTENT, MSA As hl7.MSA.CONTENT, ERR As hl7.ERR.CONTENT) As Mensajes.Response.Peticiones.Derivaciones.EnvioPeticiones.operacionResponse [ Final, ProcedureBlock = 1, SoapAction = "http://FUERTEVENTURA.Servicios/Asentimientos/ProcesarACK", SoapBindingStyle = document, SoapBodyUse = literal, SoapMessageName = ACK, SoapRequestMessage = ORM_O01, WebMethod ]

After:

Method ProcesarPeticion(MSH As hl7.MSH.CONTENT, NTE As hl7.NTE.CONTENT, ORMO01PATIENT As hl7.ORMO01.PATIENT.CONTENT(XMLNAME="ORM_O01.PATIENT"), ORMO01ORDER As hl7.ORMO01.ORDER.CONTENT(XMLNAME="ORM_O01.ORDER"), SFT As hl7.SFT.CONTENT, MSA As hl7.MSA.CONTENT, ERR As hl7.ERR.CONTENT) As %XML.String(MAXLEN="") [ Final, ProcedureBlock = 1, SoapAction = "http://FUERTEVENTURA.Servicios/Asentimientos/ProcesarACK", SoapBindingStyle = document, SoapBodyUse = literal, SoapMessageName = ACK, SoapRequestMessage = ORM_O01, WebMethod ]

In addition we have converted the Ens.Response Message to XML with the following code:

;30/01/2024 convertir a XML para quitar las etiquetas SOAP sobrantes:
set writer=##class(%XML.Writer).%New()
set status=writer.OutputToString()
If $$$ISERR(status) Do $system.OBJ.DisplayError(status)
set status=writer.RootObject(response)
If $$$ISERR(status) Do $system.OBJ.DisplayError(status) set pResponse = writer.GetXMLString()
$$$LOGALERT("pResponse: "_pResponse) ;set inicioCabeceras = "<?xml version=""1.0"" encoding=""UTF-8""?><ACK xmlns=""urn:hl7-org:v2xml"">"
;$$$LOGINFO("inicioCabeceras: "_inicioCabeceras)
set sinInicio = $PIECE(pResponse,"<operacionResponse>",2)
$$$LOGINFO("sinInicio: "_sinInicio)
set sinInicioFinal = $PIECE(sinInicio,"</operacionResponse>",1)
$$$LOGINFO("sinInicioFinal: "_sinInicioFinal)
set finalCabeceras = "</ACK>"
$$$LOGINFO("finalCabeceras: "_finalCabeceras)
;set mensajeACKcompleto = inicioCabeceras_sinInicioFinal_finalCabeceras
set mensajeACKcompleto = sinInicioFinal
$$$LOGINFO("mensajeACKcompleto: "_mensajeACKcompleto) ;quit response
quit mensajeACKcompleto
 

Being the Service's full code as we show:

Class Servicios.Peticiones.Derivaciones.Gestionv01r00 Extends EnsLib.SOAP.Service [ ClassType = "", Inheritance = right, ProcedureBlock ]
{

Parameter ADAPTER = "EnsLib.SOAP.InboundAdapter";

/// Nombre del WebService.
Parameter SERVICENAME = "Gestion";

/// Namespace SOAP para el Servicio Web
Parameter NAMESPACE = "urn:hl7-org:v2xml";

/// Se utilizarán namespaces de clases referenciadas en WSDL.
Parameter USECLASSNAMESPACES = 1;

Method ProcesarPeticion(MSH As hl7.MSH.CONTENT, NTE As hl7.NTE.CONTENT, ORMO01PATIENT As hl7.ORMO01.PATIENT.CONTENT(XMLNAME="ORM_O01.PATIENT"), ORMO01ORDER As hl7.ORMO01.ORDER.CONTENT(XMLNAME="ORM_O01.ORDER"), SFT As hl7.SFT.CONTENT, MSA As hl7.MSA.CONTENT, ERR As hl7.ERR.CONTENT) As %XML.String(MAXLEN="") [ Final, ProcedureBlock = 1, SoapAction = "http://FUERTEVENTURA.Servicios/Asentimientos/ProcesarACK", SoapBindingStyle = document, SoapBodyUse = literal, SoapMessageName = ACK, SoapRequestMessage = ORM_O01, WebMethod ]
{
	set request = ##class(Mensajes.Request.Peticiones.Derivaciones.EnvioPeticiones.operacionRequest).%New()
	set request.MSH = MSH
	do request.NTE.Insert(NTE)
	set request.ORMO01PATIENT = ORMO01PATIENT
	do request.ORMO01ORDER.Insert(ORMO01ORDER)
	
	set tSC = ..SendRequestSync("EnrutadorGestionDerivaciones",request,.response)
	
	;30/01/2024 convertir a XML para quitar las etiquetas SOAP sobrantes:
	set writer=##class(%XML.Writer).%New()
	set status=writer.OutputToString()
	If $$$ISERR(status)

	Do $system.OBJ.DisplayError(status)
	set status=writer.RootObject(response)
	If $$$ISERR(status) Do $system.OBJ.DisplayError(status)

	set pResponse = writer.GetXMLString()
	$$$LOGALERT("pResponse: "_pResponse)
	
	;set inicioCabeceras = "<?xml version=""1.0"" encoding=""UTF-8""?><ACK xmlns=""urn:hl7-org:v2xml"">"
	;$$$LOGINFO("inicioCabeceras: "_inicioCabeceras)
	set sinInicio = $PIECE(pResponse,"<operacionResponse>",2)
	$$$LOGINFO("sinInicio: "_sinInicio)
	set sinInicioFinal = $PIECE(sinInicio,"</operacionResponse>",1)
	$$$LOGINFO("sinInicioFinal: "_sinInicioFinal)
	set finalCabeceras = "</ACK>"
	$$$LOGINFO("finalCabeceras: "_finalCabeceras)
	;set mensajeACKcompleto = inicioCabeceras_sinInicioFinal_finalCabeceras
	set mensajeACKcompleto = sinInicioFinal
	$$$LOGINFO("mensajeACKcompleto: "_mensajeACKcompleto)
	
	;quit response
	quit mensajeACKcompleto
}

Method OnProcessInput(pInput As EnsLib.HL7.Message) As %Status
{
   Quit ..SendRequestAsync("EnrutadorGestionDerivaciones",pInput)
}

}

When we execute it, the $$$LOGINFO("mensajeACKcompleto: "_mensajeACKcompleto) does outputs the desired output:

<MSH xmlns:s01="urn:hl7-org:v2xml">
	<s01:MSH.1>|</s01:MSH.1>
	<s01:MSH.2>
		<![CDATA[^~\&]]>
	</s01:MSH.2>
	<s01:MSH.3>
		<s01:HD.1>sistemaExterno</s01:HD.1>
	</s01:MSH.3>
	<s01:MSH.4>
		<s01:HD.1>scs</s01:HD.1>
		<s01:HD.2>350290</s01:HD.2>
	</s01:MSH.4>
	<s01:MSH.5>
		<s01:HD.1>HGF</s01:HD.1>
	</s01:MSH.5>
	<s01:MSH.6>
		<s01:HD.1>EXTHL7</s01:HD.1>
	</s01:MSH.6>
	<s01:MSH.7>
		<s01:TS.1>20240130110908</s01:TS.1>
	</s01:MSH.7>
	<s01:MSH.9>
		<s01:MSG.1>ACK</s01:MSG.1>
	</s01:MSH.9>
	<s01:MSH.10>70589905</s01:MSH.10>
	<s01:MSH.11>
		<s01:PT.1>P</s01:PT.1>
	</s01:MSH.11>
	<s01:MSH.12>
		<s01:VID.1>2.5</s01:VID.1>
	</s01:MSH.12>
	<s01:MSH.13>1</s01:MSH.13>
	<s01:MSH.15>AL</s01:MSH.15>
	<s01:MSH.16>AL</s01:MSH.16>
	<s01:MSH.18>ASCII</s01:MSH.18>
</MSH>
<MSA xmlns:s01="urn:hl7-org:v2xml">
	<s01:MSA.1>AA</s01:MSA.1>
</MSA>

However, when we see the response being replied by the SOAP Service to the SoapUI it shows the extra XML tag "<ProcesarPeticionResult>":

<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>
		<ACK xmlns="urn:hl7-org:v2xml">
			<ProcesarPeticionResult>
				<MSH xmlns:s01="urn:hl7-org:v2xml">
					<s01:MSH.1>|</s01:MSH.1>
					<s01:MSH.2>^~\&amp;</s01:MSH.2>
					<s01:MSH.3>
						<s01:HD.1>sistemaExterno</s01:HD.1>
					</s01:MSH.3>
					<s01:MSH.4>
						<s01:HD.1>scs</s01:HD.1>
						<s01:HD.2>350290</s01:HD.2>
					</s01:MSH.4>
					<s01:MSH.5>
						<s01:HD.1>HGF</s01:HD.1>
					</s01:MSH.5>
					<s01:MSH.6>
						<s01:HD.1>EXTHL7</s01:HD.1>
					</s01:MSH.6>
					<s01:MSH.7>
						<s01:TS.1>20240130110908</s01:TS.1>
					</s01:MSH.7>
					<s01:MSH.9>
						<s01:MSG.1>ACK</s01:MSG.1>
					</s01:MSH.9>
					<s01:MSH.10>70589905</s01:MSH.10>
					<s01:MSH.11>
						<s01:PT.1>P</s01:PT.1>
					</s01:MSH.11>
					<s01:MSH.12>
						<s01:VID.1>2.5</s01:VID.1>
					</s01:MSH.12>
					<s01:MSH.13>1</s01:MSH.13>
					<s01:MSH.15>AL</s01:MSH.15>
					<s01:MSH.16>AL</s01:MSH.16>
					<s01:MSH.18>ASCII</s01:MSH.18>
				</MSH>
				<MSA xmlns:s01="urn:hl7-org:v2xml">
					<s01:MSA.1>AA</s01:MSA.1>
				</MSA>
			</ProcesarPeticionResult>
		</ACK>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

How could we achieve to remove the undesired "<ProcesarPeticionResult>" XML tag?

Thanks for your time.

Thanks for your help.

Thanks for your replies.

Could you please, help us? By pointing some documentation or linking to some example to address this need?

Thanks for your answers.