Question
· Jun 11

Base64Encode adding to SOAP Request

I am having a hard time trying to figure out the following...

Within a DTC, I was able to take the a EnsLib.HL7.Message source and using

set a= $System.Encryption.Base64Encode(source.RawContent)
set encodedMessage=$Get(a)

to take the HL7 message encode it and add it to the Data Class as a string to be sent to an Operation to be sent out as a SOAP Request. 

However to make it more universal I tried doing this within a copy of EnsLib.HL7.SOAPOperation

Method SendMessage(pMsgOut As EnsLib.HL7.Message, Output pMsgIn As EnsLib.HL7.Message, pExpectedSequenceNumber As %String) As %Status
{
 Set tSourceId=$Piece(pMsgOut.Source,$C(13))
  set CBORDRequest = ##class(osuwmc.Nutrition.OSU.CBOARDNetMenuRequest.SendMessageRequest).%New()
  set a = $SYSTEM.Encryption.Base64Encode((pMsgOut.RawContent))
  set CBORDRequest.key = ..APIKey
  set CBORDRequest.encodedMessage = $Get(a).....

I keep getting the following message from the SOAP response 

ERROR #6248: SOAP response is a SOAP fault: <Fault><Code><Value>S:Receiver</Value></Code><Reason><Text xml:lang="en">Last encoded character (before the paddings if any) is a valid base 64 alphabet but not a possible value</Text></Reason></Fault>

When I enable ^ISCSOAP, I am seeing the following...

<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://www.w3.org/2003/05/soap-envelope' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:s='http://www.w3.org/2001/XMLSchema'>
  <SOAP-ENV:Body><SendMessage xmlns="http://www.cbord.com/msg/"><key xsi:type="s:string">"15307151340368691768"</key><encodedMessage xsi:type="s:string">16@osuwmc.Nutrition.OSU.CBOARDNetMenuRequest.SendMessageRequest</encodedMessage></SendMessage></SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Could someone explain what I might be doing wrong?
 

$ZV: IRIS for UNIX (Red Hat Enterprise Linux 8 for x86-64) 2024.1 (Build 267_2U) Tue Apr 30 2024 16:06:39 EDT [HealthConnect:7.2.0-1.r1]
Discussion (4)2
Log in or sign up to continue

From the ISCSOAP log it's evident that the the content of encodedMessage property/tag is not the encoded HL7 raw message but it was assigned with an oref (object reference, an object instance) of the osuwmc.Nutrition.OSU.CBOARDNetMenuRequest.SendMessageRequest class.

This is not what the code you posted is doing, so I guess the actual code is different or the encodedMessage property is set to an oref after the code you posted.

It looks like somewhere after that code there is a:

Set CBORDRequest.encodedMessage=CBORDRequest

Beside that, my curiosity:

set a = $SYSTEM.Encryption.Base64Encode((pMsgOut.RawContent))
Why two parenthesis?

set CBORDRequest.encodedMessage = $Get(a)
Why using $Get for a variable that is indeed/for sure defined?

Not sure I am following, the idea was to take the HL7 message, encode it, and put it into the osuwmc.Nutrition.OSU.CBOARDNetMenuRequest.SendMessageRequest  as the encodedMessage. Using the osuwmc.Nutrition.OSU.CBOARDNetMenuRequest.SendMessageRequest  to pass to the Web Service Class to send outbound to the vendor.

The two Parenthesis was a typo, and I was using the $Get(a) to dereference the %Stream to a string for the osuwmc.Nutrition.OSU.CBOARDNetMenuRequest.SendMessageRequest.

The Soap wizard created the osuwmc.Nutrition.OSU.CBOARDNetMenuRequest.SendMessageRequest as the vendor requires a key value and encoded message in the body of the soap request.