Connecting to Quest Lab 360 Using SOAP

How the plumbing works


The Quest 360 interface uses HTTP basic authentication over HTTPS which is quite easy to implement. The error messages the web service gave good hints that this would be the case. It’s a very common way to implement authentication with web services. If you get the return HTTP code of 401 it indicates the user name and password were wrong.

Then it was a matter of taking example SOAP envelope from the Quest diagnostics documentation and slotting in the HL7 message payload encoding it in base64.

That’s what this code does:

T = [==[<soapenv:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soapenv="" xmlns:ord="">
      <ord:submitOrder soapenv:encodingStyle="">
         <order xsi:type="java:Order" xs:type="type:Order" xmlns:java="java:com.medplus.serviceHub.orders.webservice" xmlns:xs="">
            <hl7Order xsi:type="xsd:base64Binary">${globalCleanHL7}</hl7Order>

function MakePayload(HL7)
   local P = xml.parse{data=T}
       = base64.enc(HL7)
   return P 

I used a simple approach of defining an XML template and then slotting in the base64 encoded message. From there it’s a matter of calling the web service:

function PlaceOrder(HL7, User, Password) 
   local E = MakePayload(HL7)
   local D ={
         auth={username=User, password=Password},
      body=E:S(), live=true}
   return xml.parse{data=D}

It wasn’t all that hard to get that working, the since Translator gives us immediate feedback with the error messages; which made it simple to figure out the required Content-Type and SOAPAction headers.

The next step is to decipher what we got back, there are three of possibilities:

  • A SOAP fault response if you really screw things up like sending an empty string instead of an HL7 order message
  • Or a normal response, containing a valid HL7 message
  • A normal response, containing error information related to the HL7 message

When the Quest interface returns an error we need to identify whether it’s BEA logic stuff or the core system. It’s a rather leaky abstraction! So far the following code seems to be adequate to figure out what type of response we have and extract error messages in a useful manner:

-- Returns nil if we do not have a SOAP fault response
function IsFault(X)  
   return X["env:Envelope"]["env:Body"]["env:Fault"] 

-- Extracts the response message from a non fault response
function GetResponse(X)
   return X["env:Envelope"]["env:Body"]

-- Extracts the error message from a fault response
function GetFault(X)
   return X["env:Envelope"]["env:Body"]["env:Fault"].

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.