Written by

Sr Application Development Analyst at The Ohio State University Wexner Medical Center
Question Scott Roth · 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 = ..APIKeyset 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'&gt;
  <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]

Comments

Enrico Parisi · Jun 11

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?

0
Scott Roth  Jun 12 to Enrico Parisi

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.

0
Enrico Parisi  Jun 12 to Scott Roth

The log from ^ISCLOG you posted does not reflect the code you posted.

Something MUST happen to the CBORDRequest.encodedMessage property AFTER the code you posted before the request is sent.

Please post as much code you can up until InvokeClient().

0