I'm trying to connect to Workday API (SOAP) from Azure Functions in .NET Core, but I'm encountering some issues with authentication.
From what I've seen, the problem comes from using authentication over transport, so I tried to use custom bindings but looks like .NET Core doesn't support it yet.
SecurityBindingElement sb = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
sb.IncludeTimestamp = false;
const int lim = Int32.MaxValue;
var timeout = TimeSpan.FromMinutes(2);
var cb = new CustomBinding(
sb,
new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8)
{
ReaderQuotas = new XmlDictionaryReaderQuotas
{
MaxDepth = lim,
MaxStringContentLength = lim,
MaxArrayLength = lim,
MaxBytesPerRead = lim,
MaxNameTableCharCount = lim
}
},
new HttpsTransportBindingElement
{
MaxReceivedMessageSize = lim,
MaxBufferSize = lim,
})
{
SendTimeout = timeout,
ReceiveTimeout = timeout
};
var client = new WorkDayAbsenceServiceReference.Absence_ManagementPortClient(cb, new EndpointAddress("https://wd3-impl-services1.workday.com/ccx/service/mytenant/Absence_Management/v33.0"));
client.ClientCredentials.UserName.UserName = "myusername";
client.ClientCredentials.UserName.Password = "mypassword";
var headers = new WorkDayAbsenceServiceReference.Workday_Common_HeaderType() {};
var requestType = new WorkDayAbsenceServiceReference.Get_Time_Off_Plan_Balances_RequestType()
{
Request_Criteria = new WorkDayAbsenceServiceReference.Time_Off_Plan_Balance_Request_CriteriaType()
{
Employee_Reference = new WorkDayAbsenceServiceReference.WorkerObjectType()
{
ID = new WorkDayAbsenceServiceReference.WorkerObjectIDType[]
{
new WorkDayAbsenceServiceReference.WorkerObjectIDType
{
type = "Employee_ID",
Value = "_0000028"
}
}
}
}
};
var test = await client.Get_Time_Off_Plan_BalancesAsync(headers, requestType);
And the error code I get :
System.Private.CoreLib: Exception while executing function: GetDaysOff. System.Private.ServiceModel: TransportSecurityBindingElement.BuildChannelFactoryCore is not supported.