Question
· Oct 21, 2016

how configure Ensemble web service to use HTTP Basic authenication

Hello, trying to figure out how to configure an Ensemble web service to use HTTP Basic authentication.  I have a web service client that will not be able to send SOAP headers.  I did not see that option at all in the documentation.  thanks

Discussion (6)0
Log in or sign up to continue

Here's what I do:

authorization64 = $G(pInput.Attributes("authorization"))
// ? valid
if ($PIECE(authorization64," ",1) '= "Basic"){
Status = ##class(%SYSTEM.Status).Error(5001, "Missing basic http authentication")
Throw ##class(%Exception.StatusException).CreateFromStatus(Status)
}
//  basic http authentication looks like this: "Basic amFhcDphYXA="
authorization = $System.Encryption.Base64Decode($PIECE(authorization64," ",2))
// decoded it looks like this: "username:password"
username = $PIECE(authorization,":",1)
password = $PIECE(authorization,":",2)