Question

This question is a bit more specific than what the title indicates. I've tried several methods, hoping to get the request XML to deserialize into an object, with nothing but problems. Read on, and please just make a suggestion for some ideas for me to look into.

The Problems:

I am stuck receiving a POST in HL7 format. This is approximately a 55k post with about 200 bytes of useful info in it. I only need to extract those few bytes. Normally, this will only be about 30 bytes, depending how many tracking numbers are sent to me. NO, I do not have any say in changing this.

This HL7 data is in standard XML format, with the exception that a lot of Attributes are used to carry data, instead of Elements. Again, I seem to be stuck with the sender doing it this way. ( My preference, and experience with web services, is the standard MS Soap/WSDL setup. )

I have used XSD.exe to create a class to contain the deserialized data ( from some sample XML that will be sent to me. ), however, XSD seems to convert all attributes to elements. When I view the resulting WCF service page, I don't see xml that looks like what I am receiving. This difference seems to be preventing the deserialization of the HL7 request? See the following abbreviated samples:
Sample of an abbreviated inbound request(because dealing with the 55k sample was killing my brain), just the first few lines:

<?xml version="1.0" encoding="utf-8"?>
<QUQI_IN300102XXX xmlns="urn:hl7-org:v3" ITSVersion="XML_1.0">
  <realmCode code="XXX" />
  <id extension="XX011111" />
  <creationTime value="20121220133424-0500" />
  <responseModeCode code="IMMEDIATE" />
  <versionCode code="V3-2010-12" />
  <interactionId extension="QUQI_IN300102XXX" />
  <processingCode code="P" />
  <processingModeCode code="T" />
  <acceptAckCode code="NE" />
  <receiver typeCode="RCV">
    <realmCode code="XXX" />
    <device>
      <realmCode code="XXX" />
      <id extension="XXXIB" assigningAuthorityName="Service" />
    </device>
  </receiver>
  <sender typeCode="SND">
    <realmCode code="XXX" />
    <device>
      <realmCode code="XXX" />
      <id assigningAuthorityName="CCC" />
    </device>
  </sender>
  <controlActEvent>
    <realmCode code="XXX" />
    <id extension="Tracking" assigningAuthorityName="TRANSTYPE" />
    <code code="Order" />
    <statusCode />
    <queryByParameter>
      <realmCode code="XXX" />
      <queryId extension="NJ011111A-20121220133343" />
      <parameterList>
        <realmCode code="XXX" />
        <accessionNum>
          <value extension="NJ011111A" />
        </accessionNum>
        <batchNumber>
          <value extension="120927001" assigningAuthorityName="ZZ1" />
          <value extension="120927002" assigningAuthorityName="ZZ1" />
        </batchNumber>



The "batchNumber" is the primary data I need to get from the inbound request.
If I view the "WCF project" service help page ( created by using the WCF REST project type nuget package, if I remember correctly ), I get:

<QUQI_IN300102QD>
  <realmCode>
<realmCode>
  <code>String content</code>
</realmCode>
<realmCode>
  <code>String content</code>
</realmCode>
  </realmCode>
  <id>
<id>
  <extension>String content</extension>
  <assigningAuthorityName>String content</assigningAuthorityName>
</id>
<id>
  <extension>String content</extension>
  <assigningAuthorityName>String content</assigningAuthorityName>
</id>
  </id>
  <creationTime>
    <QUQI_IN300102QDCreationTime>
  <value>String content</value>
   </QUQI_IN300102QDCreationTime>
  <QUQI_IN300102QDCreationTime>
    <value>String content</value>
   </QUQI_IN300102QDCreationTime>
  </creationTime>



Now, the XML that I fed into XSD.exe does not look like what the service page hands out, and for whatever reason, when I pass in the post request, it will not deserialize.

I hope that's enough information to describe my problem.

What is my best choice for a solution?
Create an MVC project and accept an XMLDoc as the post datatype, and do XML manipulations to get what I need? Or some other option?
FYI, the return data has to be inserted into the XML at some point, but I haven't gotten that far yet.

FYI, my experience with creating web services has been limited to VS. You know, File, New Project, Web Service. Then adding a proxy to the WSDL page in the consuming project and just using the thing. With, of course, a third project just containing the class objects for reference by the other two projects, and some data-access project.

Using Fiddler to compose my requests, and I have WCF tracing turned on.
What I get from the trace is:

Unable to deserialize XML body with root name 'Binary' and root namespace '' (for operation 'methodTrackQLSBatch' and contract ('ShipmentTracking', 'http://tempuri.org/')) using XmlSerializer. Ensure that the type corresponding to the XML is added to the known types collection of the service.

It DOES know the type. If I change everything around to use a very simple piece of XML, it deserializes perfectly.

Thank you in advance for any thoughts.

I guess to put it succinctly, how can I accept this large HL7 request, extract data from it, insert results into it, and then return it? ( And I can probably figure out the "return it" portion, heh. Although you never know. )

Was it helpful?

Solution

It sounds like you won't get much bang for your buck deserializing the XML in this case. If you are only interested in a small amount of the data, and in the end you just want to modify the XML and return it, just read and manipulate the XML with Linq to XML. (Eg XDocument, XElement, etc)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top