web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Consuming SOAP webservices (Codeunit) from Azure Functions.

(0) ShareShare
ReportReport
Posted on by 44
Hi, I am trying to consume a Business Central webservices (SOAP) in an Azure function. 


The problem I have is that I do not know how to enter the credentials.

I am getting this error when I try to call any procedure from my SOAP: HTTP request is unauthorized with client authentication scheme 'Anonymous'

Thank you very much.
  • Suggested answer
    raelhefn Profile Picture
    Microsoft Employee on at

    Please refer to this doc. how to generate a web service key for authentication

    docs.microsoft.com/.../web-services-authentication

    Related Topic

    community.dynamics.com/.../how-to-test-api-s-in-d365-business-central

  • ivanrjlg Profile Picture
    44 on at

    Hello, thank you very much for your answer. Currently I already have the Web Service Access Key established, and I do the test in postman as you suggest and it works perfectly, which I don't know how to pass those credentials through C # in my Azure Function.

  • Suggested answer
    ivanrjlg Profile Picture
    44 on at

    Hello, I found the solution and I want to share it with you:

    private static void InitializeEndPoint(string URI)
            {
                BasicHttpBinding myBinding = new BasicHttpBinding();
                myBinding.Security.Mode = BasicHttpSecurityMode.Transport;
                myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
                myBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
                myBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
                myBinding.MaxReceivedMessageSize = 2147483647;
                myBinding.MaxBufferPoolSize = 2147483647;   
                myBinding.MaxBufferSize = 2147483647;   
    
                EndpointAddress endPoint = new EndpointAddress(URI);
                service = new ServiceClient(myBinding, endPoint);
    
                service.ClientCredentials.UserName.UserName = "UserName";
                service.ClientCredentials.UserName.Password = "Password";
            }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 796 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 481 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 377 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans