Quantcast
Viewing all articles
Browse latest Browse all 64865

Forum Post: RE: Using OAuth for Dynamics NAV Webservices(SOAP)

Hi Rajinder, I faced with the same problem as you faced. I am sorry for much delayed reply, but just for the record, I would like to share a solution to configure Microsoft Dynamics NAV to obtain Access token for SOAP Web services. You can obtain the Access Token in exactly the same way which is mentioned in the link you posted, and it is available as well for consuming OData Web Services. But the point is how we can send the access token in the "Authorization" request header when we consume SOAP Web Services. It is depending on how you create SOAP client application. The solution I found is to generate C# proxy classes by using wsdl.exe, and override SoapHttpClientProtocol.GetWebRequest Method like the following C# code example: public partial class Customer_Service : System.Web.Services.Protocols.SoapHttpClientProtocol { // Added for Azure OAuth Authentication public string AuthorizationHeader { get; set; } protected override System.Net.WebRequest GetWebRequest(Uri uri) { var request = base.GetWebRequest(uri); request.Headers.Add("Authorization", AuthorizationHeader); return request; } ... And then, you have to generate the Access Token by using Azure Active Directory Authentication Library (ADAL) and set it to the member variable of the subclass of SoapHttpClientProtocol like the following code: var az_authority = new AuthenticationContext({AZ_AUTHORITY}); var az_credential = new UserPasswordCredential({AZ_USERNAME}, {AZ_PASSWORD}); var az_auth_result = az_authority.AcquireTokenAsync( {AZ_SERVER_APP_ID_URI}, {AZ_CLIENT_ID}, az_credential ).Result; Customer_Service c = new Customer_Service(); c.AuthorizationHeader = az_auth_result.CreateAuthorizationHeader(); This is how I obtain the Access Token for consuming SOAP Web Services. Please let me know if you have any questions, and I hope this could be of some help. Best regards, Seiji

Viewing all articles
Browse latest Browse all 64865

Trending Articles