向服务发送 SOAP 请求:错误 #6237:意外标记 MSH(第 5 行)
Sending SOAP request to service: ERROR #6237: Unexpected tag MSH (Line 5)
这里我们有 WSDL
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="http://LAPALMA.Servicios/Interconsulta" xmlns:s1="urn:hl7-org:v2xml" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="http://LAPALMA.Servicios/Interconsulta">
<types>
<s:schema targetNamespace="urn:hl7-org:v2xml">
<s:element name="ACKAplicacionER7">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" name="mensaje" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ACKAplicacionXML">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" name="mensaje" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="PeticionER7">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" name="mensaje" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="PeticionXML">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" name="mensaje" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</types>
<message name="ACKAplicacionER7SoapIn">
<part name="parameters" element="s1:ACKAplicacionER7"/>
</message>
<message name="ACKAplicacionXMLSoapIn">
<part name="parameters" element="s1:ACKAplicacionXML"/>
</message>
<message name="PeticionER7SoapIn">
<part name="parameters" element="s1:PeticionER7"/>
</message>
<message name="PeticionXMLSoapIn">
<part name="parameters" element="s1:PeticionXML"/>
</message>
<portType name="PeticionInterconsultav01r00Soap">
<operation name="ACKAplicacionER7">
<input message="s0:ACKAplicacionER7SoapIn"/>
</operation>
<operation name="ACKAplicacionXML">
<input message="s0:ACKAplicacionXMLSoapIn"/>
</operation>
<operation name="PeticionER7">
<input message="s0:PeticionER7SoapIn"/>
</operation>
<operation name="PeticionXML">
<input message="s0:PeticionXMLSoapIn"/>
</operation>
</portType>
<binding name="PeticionInterconsultav01r00Soap" type="s0:PeticionInterconsultav01r00Soap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="ACKAplicacionER7">
<soap:operation soapAction="http://LAPALMA.Servicios/Interconsulta/ACKAplicacionER7" style="document"/>
<input>
<soap:body use="literal"/>
</input>
</operation>
<operation name="ACKAplicacionXML">
<soap:operation soapAction="http://LAPALMA.Servicios/Interconsulta/ACKAplicacionXML" style="document"/>
<input>
<soap:body use="literal"/>
</input>
</operation>
<operation name="PeticionER7">
<soap:operation soapAction="http://LAPALMA.Servicios/Interconsulta/PeticionER7" style="document"/>
<input>
<soap:body use="literal"/>
</input>
</operation>
<operation name="PeticionXML">
<soap:operation soapAction="http://LAPALMA.Servicios/Interconsulta/PeticionXML" style="document"/>
<input>
<soap:body use="literal"/>
</input>
</operation>
</binding>
<service name="PeticionInterconsultav01r00">
<port name="PeticionInterconsultav01r00Soap" binding="s0:PeticionInterconsultav01r00Soap">
<soap:address location="http://10.136.4.141:57772/csp/esblapalma/Servicios.Interconsulta.PeticionInterconsultav01r00.cls"/>
</port>
</service>
我想向服务发送 SOAP 请求 "PeticionXML"
我写了以下请求:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:hl7-org:v2xml">
<soapenv:Header/>
<soapenv:Body>
<ORM_O01 xmlns="urn:hl7-org:v2xml">
<MSH>
<MSH.1>|</MSH.1>
<MSH.2>^~\&</MSH.2>
<MSH.3>
<HD.1>sistemaExterno</HD.1>
</MSH.3>
<MSH.4>
<HD.1>12010520</HD.1>
<HD.2>ARRECIFE, C.L.</HD.2>
</MSH.4>
<MSH.5>
<HD.1>350228</HD.1>
</MSH.5>
<MSH.6>
<HD.1>EXTHL7</HD.1>
</MSH.6>
<MSH.7>
<TS.1>20191009103838</TS.1>
</MSH.7>
<MSH.8>user:pass</MSH.8>
<MSH.9>
<MSG.1>ORM</MSG.1>
<MSG.2>O01</MSG.2>
<MSG.3>ORM_O01</MSG.3>
</MSH.9>
<MSH.10>394522033</MSH.10>
<MSH.11>
<PT.1>E</PT.1>
</MSH.11>
<MSH.12>
<VID.1>2.5</VID.1>
</MSH.12>
<MSH.13>1</MSH.13>
<MSH.16>AL</MSH.16>
<MSH.18>ASCII</MSH.18>
</MSH>
<ORM_O01.PATIENT>
<PID>
<PID.1>1</PID.1>
<PID.2>
<CX.1>PRTF810354912013</CX.1>
</PID.2>
<PID.4>
<CX.1>481842</CX.1>
</PID.4>
<PID.5>
<XPN.1>
<FN.1>PACIENTE1583</FN.1>
</XPN.1>
<XPN.2>PRUEBATF</XPN.2>
<XPN.3>TFPRUEBA</XPN.3>
</PID.5>
<PID.7>
<TS.1>19810314000000</TS.1>
</PID.7>
<PID.8>F</PID.8>
<PID.13>
<XTN.1>928000000</XTN.1>
</PID.13>
<PID.19>381025482253</PID.19>
<PID.30>N</PID.30>
<PID.31>N</PID.31>
</PID>
<PD1>
<PD1.1>1</PD1.1>
</PD1>
<ORM_O01.PATIENT_VISIT>
<PV1>
<PV1.1>1</PV1.1>
<PV1.2>1</PV1.2>
<PV1.7>
<XCN.1>NOMBRE1 APELLIDO1 APELLIDO2</XCN.1>
</PV1.7>
<PV1.8>
<XCN.1>1201050106L</XCN.1>
</PV1.8>
<PV1.10>APLA</PV1.10>
<PV1.11>
<PL.1>201052</PL.1>
</PV1.11>
<PV1.15>12010520</PV1.15>
<PV1.30>00010101</PV1.30>
<PV1.35>00010101</PV1.35>
</PV1>
</ORM_O01.PATIENT_VISIT>
</ORM_O01.PATIENT>
<ORM_O01.ORDER>
<ORC>
<ORC.1>NW</ORC.1>
<ORC.2>
<EI.1>77833</EI.1>
</ORC.2>
<ORC.7>
<TQ.6>1</TQ.6>
</ORC.7>
<ORC.8>
<EIP.1>
<EI.1>77833</EI.1>
</EIP.1>
</ORC.8>
<ORC.10>
<XCN.1>99999999A</XCN.1>
</ORC.10>
<ORC.13>
<PL.1>CON</PL.1>
</ORC.13>
<ORC.16>
<CE.1>PC</CE.1>
<CE.2>100 PRUEBA DE ESFUERZO</CE.2>
</ORC.16>
</ORC>
<ORM_O01.ORDER_DETAIL>
<ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
<OBR>
<OBR.4>
<CE.1>IAP_CAR345</CE.1>
<CE.2>Paciente Cardiológico Continuo</CE.2>
</OBR.4>
<OBR.18>INC</OBR.18>
<OBR.19>INC</OBR.19>
</OBR>
</ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
<NTE>
<NTE.3>Datos clínicos de interés%%%MOTIVO DE INTERCONSULTA: Prueba \X000d\X000d\JUICIO DIAGNÓSTICO: AMIGDALITIS AGUDA</NTE.3>
</NTE>
</ORM_O01.ORDER_DETAIL>
</ORM_O01.ORDER>
</ORM_O01>
</soapenv:Body>
</soapenv:Envelope>
当我使用 SoapUI 发送请求时,它输出:
#ERROR 6237: Unexpected tag in XML: MSH (ends at line 5, character 12)
<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:Client</faultcode>
<faultstring>Mensaje SOAP mal creado.</faultstring>
<detail>
<error xmlns="http://LAPALMA.Servicios/Interconsulta">
<text>ERROR #6237: Etiqueta inesperada en la entrada XML: MSH (finaliza en la línea 5, carácter 12).</text>
</error>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我已经使用终端连接到服务器,日志输出:
10/14/2019 10:45:23 *********************
Input to Web service with SOAP action = "http://LAPALMA.Servicios/Interconsulta/PeticionXML"
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:hl7-org:v2xml">
<soapenv:Header/>
<soapenv:Body>
<ORM_O01 xmlns="urn:hl7-org:v2xml">
<MSH>
<MSH.1>|</MSH.1>
<MSH.2>^~\&</MSH.2>
<MSH.3>
<HD.1>sistemaExterno</HD.1>
</MSH.3>
<MSH.4>
<HD.1>12010520</HD.1>
<HD.2>ARRECIFE, C.L.</HD.2>
</MSH.4>
<MSH.5>
<HD.1>350228</HD.1>
</MSH.5>
<MSH.6>
<HD.1>EXTHL7</HD.1>
</MSH.6>
<MSH.7>
<TS.1>20191009103838</TS.1>
</MSH.7>
<MSH.8>dragoaeint:pass</MSH.8>
<MSH.9>
<MSG.1>ORM</MSG.1>
<MSG.2>O01</MSG.2>
<MSG.3>ORM_O01</MSG.3>
</MSH.9>
<MSH.10>394522033</MSH.10>
<MSH.11>
<PT.1>E</PT.1>
</MSH.11>
<MSH.12>
<VID.1>2.5</VID.1>
</MSH.12>
<MSH.13>1</MSH.13>
<MSH.16>AL</MSH.16>
<MSH.18>ASCII</MSH.18>
</MSH>
<ORM_O01.PATIENT>
<PID>
<PID.1>1</PID.1>
<PID.2>
<CX.1>PRTF810354912013</CX.1>
</PID.2>
<PID.4>
<CX.1>481842</CX.1>
</PID.4>
<PID.5>
<XPN.1>
<FN.1>PACIENTE1583</FN.1>
</XPN.1>
<XPN.2>PRUEBATF</XPN.2>
<XPN.3>TFPRUEBA</XPN.3>
</PID.5>
<PID.7>
<TS.1>19810314000000</TS.1>
</PID.7>
<PID.8>F</PID.8>
<PID.13>
<XTN.1>928000000</XTN.1>
</PID.13>
<PID.19>381025482253</PID.19>
<PID.30>N</PID.30>
<PID.31>N</PID.31>
</PID>
<PD1>
<PD1.1>1</PD1.1>
</PD1>
<ORM_O01.PATIENT_VISIT>
<PV1>
<PV1.1>1</PV1.1>
<PV1.2>1</PV1.2>
<PV1.7>
<XCN.1>NOMBRE1 APELLIDO1 APELLIDO2</XCN.1>
</PV1.7>
<PV1.8>
<XCN.1>1201050106L</XCN.1>
</PV1.8>
<PV1.10>APLA</PV1.10>
<PV1.11>
<PL.1>201052</PL.1>
</PV1.11>
<PV1.15>12010520</PV1.15>
<PV1.30>00010101</PV1.30>
<PV1.35>00010101</PV1.35>
</PV1>
</ORM_O01.PATIENT_VISIT>
</ORM_O01.PATIENT>
<ORM_O01.ORDER>
<ORC>
<ORC.1>NW</ORC.1>
<ORC.2>
<EI.1>77833</EI.1>
</ORC.2>
<ORC.7>
<TQ.6>1</TQ.6>
</ORC.7>
<ORC.8>
<EIP.1>
<EI.1>77833</EI.1>
</EIP.1>
</ORC.8>
<ORC.10>
<XCN.1>99999999A</XCN.1>
</ORC.10>
<ORC.13>
<PL.1>CON</PL.1>
</ORC.13>
<ORC.16>
<CE.1>PC</CE.1>
<CE.2>100 PRUEBA DE ESFUERZO</CE.2>
</ORC.16>
</ORC>
<ORM_O01.ORDER_DETAIL>
<ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
<OBR>
<OBR.4>
<CE.1>IAP_CAR345</CE.1>
<CE.2>Paciente Cardiológico Continuo</CE.2>
</OBR.4>
<OBR.18>INC</OBR.18>
<OBR.19>INC</OBR.19>
</OBR>
</ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
<NTE>
<NTE.3>Datos clínicos de interés%%%MOTIVO DE INTERCONSULTA: Prueba \X000d\X000d\JUICIO DIAGNÓSTICO: AMIGDALITIS AGUDA</NTE.3>
</NTE>
</ORM_O01.ORDER_DETAIL>
</ORM_O01.ORDER>
</ORM_O01>
</soapenv:Body>
</soapenv:Envelope>
---------------
Validate Security header: action="http://LAPALMA.Servicios/Interconsulta/PeticionXML"
10/14/2019 10:45:23 *********************
Output from Web service with SOAP action = "http://LAPALMA.Servicios/Interconsulta/PeticionXML"
<?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:Client</faultcode>
<faultstring>Mensaje SOAP mal creado.</faultstring>
<detail>
<error xmlns='http://LAPALMA.Servicios/Interconsulta'>
<text>ERROR #6237: Etiqueta inesperada en la entrada XML: MSH (finaliza en la línea 5, carácter 12).</text>
</error>
</detail>
</SOAP-ENV:Fault>
我还检查了客户端 "PeticionXML" 需要参数 MSH:
Method operacion(ByRef MSH As WSCLIENTE.Farmacia.hl71.MSH.CONTENT(REFELEMENTQUALIFIED=0,REFNAMESPACE="urn:hl7-org:v2xml",XMLREF=1,REQUIRED=1), Output SFT As %ListOfObjects(ELEMENTTYPE="WSCLIENTE.Farmacia.hl71.SFT.CONTENT",XMLPROJECTION="element",REFELEMENTQUALIFIED=0,REFNAMESPACE="urn:hl7-org:v2xml",XMLNAME="SFT",XMLREF=1), ByRef MSA As WSCLIENTE.Farmacia.hl71.MSA.CONTENT(REFELEMENTQUALIFIED=0,REFNAMESPACE="urn:hl7-org:v2xml",XMLREF=1,REQUIRED=1), ByRef ERR As %ListOfObjects(ELEMENTTYPE="WSCLIENTE.Farmacia.hl71.ERR.CONTENT",XMLPROJECTION="element",REFELEMENTQUALIFIED=0,REFNAMESPACE="urn:hl7-org:v2xml",XMLNAME="ERR",XMLREF=1), NTE As %ListOfObjects(ELEMENTTYPE="WSCLIENTE.Farmacia.hl71.NTE.CONTENT",XMLPROJECTION="element",REFELEMENTQUALIFIED=0,REFNAMESPACE="urn:hl7-org:v2xml",XMLNAME="NTE",XMLREF=1), ORRO02RESPONSE As WSCLIENTE.Farmacia.hl71.ORRO02.RESPONSE.CONTENT(REFELEMENTQUALIFIED=0,REFNAMESPACE="urn:hl7-org:v2xml",XMLNAME="ORR_O02.RESPONSE",XMLREF=1,REQUIRED=1)) [ Final, ProcedureBlock = 1, SoapBindingStyle = document, SoapBodyUse = literal, WebMethod ]
{
Do (..WebMethod("operacion","ORR_O02")).Invoke($this,"http://[host]:[puerto]/adm/HL7Service",.MSH,.SFT,.MSA,.ERR,.NTE,.ORRO02RESPONSE)
}
此外,这里是为服务 PeticionXML 编写的代码:
Method PeticionXML(mensaje As %String) As %SOAP.OneWay [ Final, ProcedureBlock = 1, SoapAction = "http://LAPALMA.Servicios/Interconsulta/PeticionXML", SoapBindingStyle = document, SoapBodyUse = literal, WebMethod ]
{
$$$LOGINFO("test")
set p = ##class(%GlobalCharacterStream).%New()
do p.Write(mensaje)
//#dim msgER7 As EnsLib.HL7.Message
set msgER7 = ##class(EnsLib.HL7.Message).%New()
set msgER7 = ##class(ITB.HL7.Util.Convert).XMLToER7(p,.tSC,"2.5")
set tSC = ..SendRequestAsync("EnrutadorVisadoMedicamento",msgER7)
Quit $$$OK
}
我也看过:
Getting error while sending SOAP request
What does <![CDATA[]]> in XML mean?
https://community.intersystems.com/question428321/answer428461
https://community.intersystems.com/post/soap-services-cach%C3%A9-os-ignore-order-elements
https://cedocs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GSOAP_debug_info_soap_log
我发现我们需要将 HL7 ORM_O01 封装在一个字段中。那么我们的要求就是:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:hl7-org:v2xml">
<soapenv:Header/>
<soapenv:Body>
<urn:PeticionXML>
<mensaje>
<![CDATA[<ORM_O01 xmlns="urn:hl7-org:v2xml">
<MSH>
<MSH.1>|</MSH.1>
<MSH.2>^~\&</MSH.2>
<MSH.3>
<HD.1>sistemaExterno</HD.1>
</MSH.3>
<MSH.4>
<HD.1>12010520</HD.1>
<HD.2>ARRECIFE, C.L.</HD.2>
</MSH.4>
<MSH.5>
<HD.1>350228</HD.1>
</MSH.5>
<MSH.6>
<HD.1>EXTHL7</HD.1>
</MSH.6>
<MSH.7>
<TS.1>20191009103838</TS.1>
</MSH.7>
<MSH.8>dragoaeint:pass</MSH.8>
<MSH.9>
<MSG.1>ORM</MSG.1>
<MSG.2>O01</MSG.2>
<MSG.3>ORM_O01</MSG.3>
</MSH.9>
<MSH.10>394522033</MSH.10>
<MSH.11>
<PT.1>E</PT.1>
</MSH.11>
<MSH.12>
<VID.1>2.5</VID.1>
</MSH.12>
<MSH.13>1</MSH.13>
<MSH.16>AL</MSH.16>
<MSH.18>ASCII</MSH.18>
</MSH>
<ORM_O01.PATIENT>
<PID>
<PID.1>1</PID.1>
<PID.2>
<CX.1>PRTF810354912013</CX.1>
</PID.2>
<PID.4>
<CX.1>481842</CX.1>
</PID.4>
<PID.5>
<XPN.1>
<FN.1>PACIENTE1583</FN.1>
</XPN.1>
<XPN.2>PRUEBATF</XPN.2>
<XPN.3>TFPRUEBA</XPN.3>
</PID.5>
<PID.7>
<TS.1>19810314000000</TS.1>
</PID.7>
<PID.8>F</PID.8>
<PID.13>
<XTN.1>928000000</XTN.1>
</PID.13>
<PID.19>381025482253</PID.19>
<PID.30>N</PID.30>
<PID.31>N</PID.31>
</PID>
<PD1>
<PD1.1>1</PD1.1>
</PD1>
<ORM_O01.PATIENT_VISIT>
<PV1>
<PV1.1>1</PV1.1>
<PV1.2>1</PV1.2>
<PV1.7>
<XCN.1>NOMBRE1 APELLIDO1 APELLIDO2</XCN.1>
</PV1.7>
<PV1.8>
<XCN.1>1201050106L</XCN.1>
</PV1.8>
<PV1.10>APLA</PV1.10>
<PV1.11>
<PL.1>201052</PL.1>
</PV1.11>
<PV1.15>12010520</PV1.15>
<PV1.30>00010101</PV1.30>
<PV1.35>00010101</PV1.35>
</PV1>
</ORM_O01.PATIENT_VISIT>
</ORM_O01.PATIENT>
<ORM_O01.ORDER>
<ORC>
<ORC.1>NW</ORC.1>
<ORC.2>
<EI.1>77833</EI.1>
</ORC.2>
<ORC.7>
<TQ.6>1</TQ.6>
</ORC.7>
<ORC.8>
<EIP.1>
<EI.1>77833</EI.1>
</EIP.1>
</ORC.8>
<ORC.10>
<XCN.1>99999999A</XCN.1>
</ORC.10>
<ORC.13>
<PL.1>CON</PL.1>
</ORC.13>
<ORC.16>
<CE.1>PC</CE.1>
<CE.2>100 PRUEBA DE ESFUERZO</CE.2>
</ORC.16>
</ORC>
<ORM_O01.ORDER_DETAIL>
<ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
<OBR>
<OBR.4>
<CE.1>IAP_CAR345</CE.1>
<CE.2>Paciente Cardiológico Continuo</CE.2>
</OBR.4>
<OBR.18>INC</OBR.18>
<OBR.19>INC</OBR.19>
</OBR>
</ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
<NTE>
<NTE.3>Datos clínicos de interés%%%MOTIVO DE INTERCONSULTA: Prueba \X000d\X000d\JUICIO DIAGNÓSTICO: AMIGDALITIS AGUDA</NTE.3>
</NTE>
</ORM_O01.ORDER_DETAIL>
</ORM_O01.ORDER>
</ORM_O01>]]>
</mensaje>
</urn:PeticionXML>
</soapenv:Body>
</soapenv:Envelope>
原因是我们要防止XML解析器分析为XML,我们的HL7标签,例如或.
这里我们有 WSDL
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="http://LAPALMA.Servicios/Interconsulta" xmlns:s1="urn:hl7-org:v2xml" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="http://LAPALMA.Servicios/Interconsulta">
<types>
<s:schema targetNamespace="urn:hl7-org:v2xml">
<s:element name="ACKAplicacionER7">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" name="mensaje" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ACKAplicacionXML">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" name="mensaje" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="PeticionER7">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" name="mensaje" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="PeticionXML">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" name="mensaje" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</types>
<message name="ACKAplicacionER7SoapIn">
<part name="parameters" element="s1:ACKAplicacionER7"/>
</message>
<message name="ACKAplicacionXMLSoapIn">
<part name="parameters" element="s1:ACKAplicacionXML"/>
</message>
<message name="PeticionER7SoapIn">
<part name="parameters" element="s1:PeticionER7"/>
</message>
<message name="PeticionXMLSoapIn">
<part name="parameters" element="s1:PeticionXML"/>
</message>
<portType name="PeticionInterconsultav01r00Soap">
<operation name="ACKAplicacionER7">
<input message="s0:ACKAplicacionER7SoapIn"/>
</operation>
<operation name="ACKAplicacionXML">
<input message="s0:ACKAplicacionXMLSoapIn"/>
</operation>
<operation name="PeticionER7">
<input message="s0:PeticionER7SoapIn"/>
</operation>
<operation name="PeticionXML">
<input message="s0:PeticionXMLSoapIn"/>
</operation>
</portType>
<binding name="PeticionInterconsultav01r00Soap" type="s0:PeticionInterconsultav01r00Soap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="ACKAplicacionER7">
<soap:operation soapAction="http://LAPALMA.Servicios/Interconsulta/ACKAplicacionER7" style="document"/>
<input>
<soap:body use="literal"/>
</input>
</operation>
<operation name="ACKAplicacionXML">
<soap:operation soapAction="http://LAPALMA.Servicios/Interconsulta/ACKAplicacionXML" style="document"/>
<input>
<soap:body use="literal"/>
</input>
</operation>
<operation name="PeticionER7">
<soap:operation soapAction="http://LAPALMA.Servicios/Interconsulta/PeticionER7" style="document"/>
<input>
<soap:body use="literal"/>
</input>
</operation>
<operation name="PeticionXML">
<soap:operation soapAction="http://LAPALMA.Servicios/Interconsulta/PeticionXML" style="document"/>
<input>
<soap:body use="literal"/>
</input>
</operation>
</binding>
<service name="PeticionInterconsultav01r00">
<port name="PeticionInterconsultav01r00Soap" binding="s0:PeticionInterconsultav01r00Soap">
<soap:address location="http://10.136.4.141:57772/csp/esblapalma/Servicios.Interconsulta.PeticionInterconsultav01r00.cls"/>
</port>
</service>
我想向服务发送 SOAP 请求 "PeticionXML"
我写了以下请求:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:hl7-org:v2xml">
<soapenv:Header/>
<soapenv:Body>
<ORM_O01 xmlns="urn:hl7-org:v2xml">
<MSH>
<MSH.1>|</MSH.1>
<MSH.2>^~\&</MSH.2>
<MSH.3>
<HD.1>sistemaExterno</HD.1>
</MSH.3>
<MSH.4>
<HD.1>12010520</HD.1>
<HD.2>ARRECIFE, C.L.</HD.2>
</MSH.4>
<MSH.5>
<HD.1>350228</HD.1>
</MSH.5>
<MSH.6>
<HD.1>EXTHL7</HD.1>
</MSH.6>
<MSH.7>
<TS.1>20191009103838</TS.1>
</MSH.7>
<MSH.8>user:pass</MSH.8>
<MSH.9>
<MSG.1>ORM</MSG.1>
<MSG.2>O01</MSG.2>
<MSG.3>ORM_O01</MSG.3>
</MSH.9>
<MSH.10>394522033</MSH.10>
<MSH.11>
<PT.1>E</PT.1>
</MSH.11>
<MSH.12>
<VID.1>2.5</VID.1>
</MSH.12>
<MSH.13>1</MSH.13>
<MSH.16>AL</MSH.16>
<MSH.18>ASCII</MSH.18>
</MSH>
<ORM_O01.PATIENT>
<PID>
<PID.1>1</PID.1>
<PID.2>
<CX.1>PRTF810354912013</CX.1>
</PID.2>
<PID.4>
<CX.1>481842</CX.1>
</PID.4>
<PID.5>
<XPN.1>
<FN.1>PACIENTE1583</FN.1>
</XPN.1>
<XPN.2>PRUEBATF</XPN.2>
<XPN.3>TFPRUEBA</XPN.3>
</PID.5>
<PID.7>
<TS.1>19810314000000</TS.1>
</PID.7>
<PID.8>F</PID.8>
<PID.13>
<XTN.1>928000000</XTN.1>
</PID.13>
<PID.19>381025482253</PID.19>
<PID.30>N</PID.30>
<PID.31>N</PID.31>
</PID>
<PD1>
<PD1.1>1</PD1.1>
</PD1>
<ORM_O01.PATIENT_VISIT>
<PV1>
<PV1.1>1</PV1.1>
<PV1.2>1</PV1.2>
<PV1.7>
<XCN.1>NOMBRE1 APELLIDO1 APELLIDO2</XCN.1>
</PV1.7>
<PV1.8>
<XCN.1>1201050106L</XCN.1>
</PV1.8>
<PV1.10>APLA</PV1.10>
<PV1.11>
<PL.1>201052</PL.1>
</PV1.11>
<PV1.15>12010520</PV1.15>
<PV1.30>00010101</PV1.30>
<PV1.35>00010101</PV1.35>
</PV1>
</ORM_O01.PATIENT_VISIT>
</ORM_O01.PATIENT>
<ORM_O01.ORDER>
<ORC>
<ORC.1>NW</ORC.1>
<ORC.2>
<EI.1>77833</EI.1>
</ORC.2>
<ORC.7>
<TQ.6>1</TQ.6>
</ORC.7>
<ORC.8>
<EIP.1>
<EI.1>77833</EI.1>
</EIP.1>
</ORC.8>
<ORC.10>
<XCN.1>99999999A</XCN.1>
</ORC.10>
<ORC.13>
<PL.1>CON</PL.1>
</ORC.13>
<ORC.16>
<CE.1>PC</CE.1>
<CE.2>100 PRUEBA DE ESFUERZO</CE.2>
</ORC.16>
</ORC>
<ORM_O01.ORDER_DETAIL>
<ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
<OBR>
<OBR.4>
<CE.1>IAP_CAR345</CE.1>
<CE.2>Paciente Cardiológico Continuo</CE.2>
</OBR.4>
<OBR.18>INC</OBR.18>
<OBR.19>INC</OBR.19>
</OBR>
</ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
<NTE>
<NTE.3>Datos clínicos de interés%%%MOTIVO DE INTERCONSULTA: Prueba \X000d\X000d\JUICIO DIAGNÓSTICO: AMIGDALITIS AGUDA</NTE.3>
</NTE>
</ORM_O01.ORDER_DETAIL>
</ORM_O01.ORDER>
</ORM_O01>
</soapenv:Body>
</soapenv:Envelope>
当我使用 SoapUI 发送请求时,它输出:
#ERROR 6237: Unexpected tag in XML: MSH (ends at line 5, character 12)
<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:Client</faultcode>
<faultstring>Mensaje SOAP mal creado.</faultstring>
<detail>
<error xmlns="http://LAPALMA.Servicios/Interconsulta">
<text>ERROR #6237: Etiqueta inesperada en la entrada XML: MSH (finaliza en la línea 5, carácter 12).</text>
</error>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我已经使用终端连接到服务器,日志输出:
10/14/2019 10:45:23 *********************
Input to Web service with SOAP action = "http://LAPALMA.Servicios/Interconsulta/PeticionXML"
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:hl7-org:v2xml">
<soapenv:Header/>
<soapenv:Body>
<ORM_O01 xmlns="urn:hl7-org:v2xml">
<MSH>
<MSH.1>|</MSH.1>
<MSH.2>^~\&</MSH.2>
<MSH.3>
<HD.1>sistemaExterno</HD.1>
</MSH.3>
<MSH.4>
<HD.1>12010520</HD.1>
<HD.2>ARRECIFE, C.L.</HD.2>
</MSH.4>
<MSH.5>
<HD.1>350228</HD.1>
</MSH.5>
<MSH.6>
<HD.1>EXTHL7</HD.1>
</MSH.6>
<MSH.7>
<TS.1>20191009103838</TS.1>
</MSH.7>
<MSH.8>dragoaeint:pass</MSH.8>
<MSH.9>
<MSG.1>ORM</MSG.1>
<MSG.2>O01</MSG.2>
<MSG.3>ORM_O01</MSG.3>
</MSH.9>
<MSH.10>394522033</MSH.10>
<MSH.11>
<PT.1>E</PT.1>
</MSH.11>
<MSH.12>
<VID.1>2.5</VID.1>
</MSH.12>
<MSH.13>1</MSH.13>
<MSH.16>AL</MSH.16>
<MSH.18>ASCII</MSH.18>
</MSH>
<ORM_O01.PATIENT>
<PID>
<PID.1>1</PID.1>
<PID.2>
<CX.1>PRTF810354912013</CX.1>
</PID.2>
<PID.4>
<CX.1>481842</CX.1>
</PID.4>
<PID.5>
<XPN.1>
<FN.1>PACIENTE1583</FN.1>
</XPN.1>
<XPN.2>PRUEBATF</XPN.2>
<XPN.3>TFPRUEBA</XPN.3>
</PID.5>
<PID.7>
<TS.1>19810314000000</TS.1>
</PID.7>
<PID.8>F</PID.8>
<PID.13>
<XTN.1>928000000</XTN.1>
</PID.13>
<PID.19>381025482253</PID.19>
<PID.30>N</PID.30>
<PID.31>N</PID.31>
</PID>
<PD1>
<PD1.1>1</PD1.1>
</PD1>
<ORM_O01.PATIENT_VISIT>
<PV1>
<PV1.1>1</PV1.1>
<PV1.2>1</PV1.2>
<PV1.7>
<XCN.1>NOMBRE1 APELLIDO1 APELLIDO2</XCN.1>
</PV1.7>
<PV1.8>
<XCN.1>1201050106L</XCN.1>
</PV1.8>
<PV1.10>APLA</PV1.10>
<PV1.11>
<PL.1>201052</PL.1>
</PV1.11>
<PV1.15>12010520</PV1.15>
<PV1.30>00010101</PV1.30>
<PV1.35>00010101</PV1.35>
</PV1>
</ORM_O01.PATIENT_VISIT>
</ORM_O01.PATIENT>
<ORM_O01.ORDER>
<ORC>
<ORC.1>NW</ORC.1>
<ORC.2>
<EI.1>77833</EI.1>
</ORC.2>
<ORC.7>
<TQ.6>1</TQ.6>
</ORC.7>
<ORC.8>
<EIP.1>
<EI.1>77833</EI.1>
</EIP.1>
</ORC.8>
<ORC.10>
<XCN.1>99999999A</XCN.1>
</ORC.10>
<ORC.13>
<PL.1>CON</PL.1>
</ORC.13>
<ORC.16>
<CE.1>PC</CE.1>
<CE.2>100 PRUEBA DE ESFUERZO</CE.2>
</ORC.16>
</ORC>
<ORM_O01.ORDER_DETAIL>
<ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
<OBR>
<OBR.4>
<CE.1>IAP_CAR345</CE.1>
<CE.2>Paciente Cardiológico Continuo</CE.2>
</OBR.4>
<OBR.18>INC</OBR.18>
<OBR.19>INC</OBR.19>
</OBR>
</ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
<NTE>
<NTE.3>Datos clínicos de interés%%%MOTIVO DE INTERCONSULTA: Prueba \X000d\X000d\JUICIO DIAGNÓSTICO: AMIGDALITIS AGUDA</NTE.3>
</NTE>
</ORM_O01.ORDER_DETAIL>
</ORM_O01.ORDER>
</ORM_O01>
</soapenv:Body>
</soapenv:Envelope>
---------------
Validate Security header: action="http://LAPALMA.Servicios/Interconsulta/PeticionXML"
10/14/2019 10:45:23 *********************
Output from Web service with SOAP action = "http://LAPALMA.Servicios/Interconsulta/PeticionXML"
<?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:Client</faultcode>
<faultstring>Mensaje SOAP mal creado.</faultstring>
<detail>
<error xmlns='http://LAPALMA.Servicios/Interconsulta'>
<text>ERROR #6237: Etiqueta inesperada en la entrada XML: MSH (finaliza en la línea 5, carácter 12).</text>
</error>
</detail>
</SOAP-ENV:Fault>
我还检查了客户端 "PeticionXML" 需要参数 MSH:
Method operacion(ByRef MSH As WSCLIENTE.Farmacia.hl71.MSH.CONTENT(REFELEMENTQUALIFIED=0,REFNAMESPACE="urn:hl7-org:v2xml",XMLREF=1,REQUIRED=1), Output SFT As %ListOfObjects(ELEMENTTYPE="WSCLIENTE.Farmacia.hl71.SFT.CONTENT",XMLPROJECTION="element",REFELEMENTQUALIFIED=0,REFNAMESPACE="urn:hl7-org:v2xml",XMLNAME="SFT",XMLREF=1), ByRef MSA As WSCLIENTE.Farmacia.hl71.MSA.CONTENT(REFELEMENTQUALIFIED=0,REFNAMESPACE="urn:hl7-org:v2xml",XMLREF=1,REQUIRED=1), ByRef ERR As %ListOfObjects(ELEMENTTYPE="WSCLIENTE.Farmacia.hl71.ERR.CONTENT",XMLPROJECTION="element",REFELEMENTQUALIFIED=0,REFNAMESPACE="urn:hl7-org:v2xml",XMLNAME="ERR",XMLREF=1), NTE As %ListOfObjects(ELEMENTTYPE="WSCLIENTE.Farmacia.hl71.NTE.CONTENT",XMLPROJECTION="element",REFELEMENTQUALIFIED=0,REFNAMESPACE="urn:hl7-org:v2xml",XMLNAME="NTE",XMLREF=1), ORRO02RESPONSE As WSCLIENTE.Farmacia.hl71.ORRO02.RESPONSE.CONTENT(REFELEMENTQUALIFIED=0,REFNAMESPACE="urn:hl7-org:v2xml",XMLNAME="ORR_O02.RESPONSE",XMLREF=1,REQUIRED=1)) [ Final, ProcedureBlock = 1, SoapBindingStyle = document, SoapBodyUse = literal, WebMethod ]
{
Do (..WebMethod("operacion","ORR_O02")).Invoke($this,"http://[host]:[puerto]/adm/HL7Service",.MSH,.SFT,.MSA,.ERR,.NTE,.ORRO02RESPONSE)
}
此外,这里是为服务 PeticionXML 编写的代码:
Method PeticionXML(mensaje As %String) As %SOAP.OneWay [ Final, ProcedureBlock = 1, SoapAction = "http://LAPALMA.Servicios/Interconsulta/PeticionXML", SoapBindingStyle = document, SoapBodyUse = literal, WebMethod ]
{
$$$LOGINFO("test")
set p = ##class(%GlobalCharacterStream).%New()
do p.Write(mensaje)
//#dim msgER7 As EnsLib.HL7.Message
set msgER7 = ##class(EnsLib.HL7.Message).%New()
set msgER7 = ##class(ITB.HL7.Util.Convert).XMLToER7(p,.tSC,"2.5")
set tSC = ..SendRequestAsync("EnrutadorVisadoMedicamento",msgER7)
Quit $$$OK
}
我也看过:
Getting error while sending SOAP request
https://community.intersystems.com/question428321/answer428461 https://community.intersystems.com/post/soap-services-cach%C3%A9-os-ignore-order-elements https://cedocs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GSOAP_debug_info_soap_log
我发现我们需要将 HL7 ORM_O01 封装在一个字段中。那么我们的要求就是:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:hl7-org:v2xml">
<soapenv:Header/>
<soapenv:Body>
<urn:PeticionXML>
<mensaje>
<![CDATA[<ORM_O01 xmlns="urn:hl7-org:v2xml">
<MSH>
<MSH.1>|</MSH.1>
<MSH.2>^~\&</MSH.2>
<MSH.3>
<HD.1>sistemaExterno</HD.1>
</MSH.3>
<MSH.4>
<HD.1>12010520</HD.1>
<HD.2>ARRECIFE, C.L.</HD.2>
</MSH.4>
<MSH.5>
<HD.1>350228</HD.1>
</MSH.5>
<MSH.6>
<HD.1>EXTHL7</HD.1>
</MSH.6>
<MSH.7>
<TS.1>20191009103838</TS.1>
</MSH.7>
<MSH.8>dragoaeint:pass</MSH.8>
<MSH.9>
<MSG.1>ORM</MSG.1>
<MSG.2>O01</MSG.2>
<MSG.3>ORM_O01</MSG.3>
</MSH.9>
<MSH.10>394522033</MSH.10>
<MSH.11>
<PT.1>E</PT.1>
</MSH.11>
<MSH.12>
<VID.1>2.5</VID.1>
</MSH.12>
<MSH.13>1</MSH.13>
<MSH.16>AL</MSH.16>
<MSH.18>ASCII</MSH.18>
</MSH>
<ORM_O01.PATIENT>
<PID>
<PID.1>1</PID.1>
<PID.2>
<CX.1>PRTF810354912013</CX.1>
</PID.2>
<PID.4>
<CX.1>481842</CX.1>
</PID.4>
<PID.5>
<XPN.1>
<FN.1>PACIENTE1583</FN.1>
</XPN.1>
<XPN.2>PRUEBATF</XPN.2>
<XPN.3>TFPRUEBA</XPN.3>
</PID.5>
<PID.7>
<TS.1>19810314000000</TS.1>
</PID.7>
<PID.8>F</PID.8>
<PID.13>
<XTN.1>928000000</XTN.1>
</PID.13>
<PID.19>381025482253</PID.19>
<PID.30>N</PID.30>
<PID.31>N</PID.31>
</PID>
<PD1>
<PD1.1>1</PD1.1>
</PD1>
<ORM_O01.PATIENT_VISIT>
<PV1>
<PV1.1>1</PV1.1>
<PV1.2>1</PV1.2>
<PV1.7>
<XCN.1>NOMBRE1 APELLIDO1 APELLIDO2</XCN.1>
</PV1.7>
<PV1.8>
<XCN.1>1201050106L</XCN.1>
</PV1.8>
<PV1.10>APLA</PV1.10>
<PV1.11>
<PL.1>201052</PL.1>
</PV1.11>
<PV1.15>12010520</PV1.15>
<PV1.30>00010101</PV1.30>
<PV1.35>00010101</PV1.35>
</PV1>
</ORM_O01.PATIENT_VISIT>
</ORM_O01.PATIENT>
<ORM_O01.ORDER>
<ORC>
<ORC.1>NW</ORC.1>
<ORC.2>
<EI.1>77833</EI.1>
</ORC.2>
<ORC.7>
<TQ.6>1</TQ.6>
</ORC.7>
<ORC.8>
<EIP.1>
<EI.1>77833</EI.1>
</EIP.1>
</ORC.8>
<ORC.10>
<XCN.1>99999999A</XCN.1>
</ORC.10>
<ORC.13>
<PL.1>CON</PL.1>
</ORC.13>
<ORC.16>
<CE.1>PC</CE.1>
<CE.2>100 PRUEBA DE ESFUERZO</CE.2>
</ORC.16>
</ORC>
<ORM_O01.ORDER_DETAIL>
<ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
<OBR>
<OBR.4>
<CE.1>IAP_CAR345</CE.1>
<CE.2>Paciente Cardiológico Continuo</CE.2>
</OBR.4>
<OBR.18>INC</OBR.18>
<OBR.19>INC</OBR.19>
</OBR>
</ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
<NTE>
<NTE.3>Datos clínicos de interés%%%MOTIVO DE INTERCONSULTA: Prueba \X000d\X000d\JUICIO DIAGNÓSTICO: AMIGDALITIS AGUDA</NTE.3>
</NTE>
</ORM_O01.ORDER_DETAIL>
</ORM_O01.ORDER>
</ORM_O01>]]>
</mensaje>
</urn:PeticionXML>
</soapenv:Body>
</soapenv:Envelope>
原因是我们要防止XML解析器分析为XML,我们的HL7标签,例如或.