none
Question about MTOM web service -- how to BASE 64 encode and get a checksum of the value? RRS feed

  • Question

  • To give some background I am creating a healthcare web service that adheres to the government mandated CORE rules described here : http://caqh.org/pdf/CLEAN5010/270-v5010.pdf

    The CORE rules require the service to use MTOM and a specific xsd > http://www.caqh.org/SOAP/WSDL/CORERule2.2.0.xsd. 

    The xsd describes many request and response types. Here is one of the response types :

      <xs:element name="COREEnvelopeBatchResultsRetrievalResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="PayloadType" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="ProcessingMode" type="BatchMode" minOccurs="1" maxOccurs="1"/>
            <xs:element name="PayloadID" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="PayloadLength" type="xs:int" minOccurs="0" maxOccurs="1"/>
            <xs:element name="TimeStamp" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="SenderID" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="ReceiverID" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="CORERuleVersion" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="CheckSum" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="Payload" type="xs:base64Binary" minOccurs="0" maxOccurs="1"/>
            <xs:element name="ErrorCode" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="ErrorMessage" type="xs:string" minOccurs="1" maxOccurs="1"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>

    I have put in bold the two elements relevant to my question. The Payload element has to be base 64 encoded, and the CheckSum element has to contain a checksum for that payload. The CORE rules description for the checksum is "Algorithm is SHA-1, Encoding is Hex."

    So currently in my WCF service contract I have a class called COREEnvelopeBatchResultsRetrievalResponse just like in the xsd and the Payload property of type byte[]

    First question : from what I understand of MTOM when you have a byte[] property it will automatically be Base64 encoded by WCF MTOM. Is that correct?

    Second question: If the above is true then how do I get the checksum of the Base64 encoded value?

    Friday, October 24, 2014 1:28 PM

All replies

  • Hi,

    Currently, you could refer to the links below:

    MTOM Encoding

    http://msdn.microsoft.com/en-us/library/ms733742(v=vs.110).aspx 

    http://stackoverflow.com/questions/22922620/bytes-read-as-utf8-string-and-converted-to-base64

    Monday, October 27, 2014 5:48 AM