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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Debugging Web Service Codeunit not attaching to WebServiceClient

(2) ShareShare
ReportReport
Posted on by 27
Hello!
 
I have a weird problem: I am unable to debug the codeunit that is exposed as a web service. 
 
I have a SOAP Request coming from Postman and the receiving codeunit. They communicate and I see the Response in POstman that says so (200 status)... 
 
However, I would like to set a breakpoint and analyze what's happening in the codeunit... and I am unable to accomplish that. 
 
I followed the tutorials and added a configuration to launch.json, below is my launch json and I start the debugger and it says: Debugger will attach to the next session of type WebServiceClient.
 
However, the debugger never enters into that breakpoint... I go into admin dashboard: environment - sessions... 
I only see sessions of type WebClient (browser)
but I dont see the session representing the WebServiceClient type onto which the debugger is supposed to attach itself... 
 
Please help 
thank you 
A.
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach: Microsoft cloud sandbox",
            "type": "al",
            "request": "attach",
            "environmentType": "Sandbox",
            "environmentName": "Example",
            "breakOnError": true,
            "breakOnRecordWrite": false,
            "longRunningSqlStatementsThreshold": 500,
            "numberOfSqlStatements": 10,
            "breakOnNext": "WebServiceClient"
        },
        {
            "name": "Microsoft cloud sandbox",
            "request": "launch",
            "type": "al",
            "environmentType": "Sandbox",
            "environmentName": "Example",
            "tenant": "123ertghj-9999-xxxx-xxxx-yyyyyyyyyyy",
            "startupObjectId": 22,
            "startupObjectType": "Page",
            "breakOnError": "All",
            "launchBrowser": true,
         "schemaUpdateMode": "ForceSync"
           
        }
    ]
}
I have the same question (0)
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,150 Super User 2025 Season 2 on at
    To debug a Web Service Codeunit and have the debugger attach to the WebServiceClient session, follow these steps:
     
    1. Ensure your Web Service is Published and Enabled:
    The codeunit must be published as a SOAP web service in your BC environment.
     
     
    2. Correct launch.json Configuration:
    Your launch.json looks mostly correct, but make sure the "breakOnNext": "WebServiceClient" matches exactly and that you’re attaching before invoking the web service call from Postman.
     
     
    3. Start Debugger Before Calling Web Service:
    Launch the debugger with the “Attach” configuration first, so it waits for the next WebServiceClient session.
     
     
    4. Invoke the Web Service Call Quickly:
    After starting the debugger, immediately send the SOAP request from Postman. The debugger attaches only if the call happens after debugger is listening.
     
     
    5. Check Environment and Permissions:
     
    Make sure you are attached to the correct sandbox environment.
     
    Your user must have debugging permissions.
     
     
     
    6. If No Session Appears:
     
    Try restarting the BC sandbox environment.
     
    Clear your VS Code cache or restart VS Code.
     
    Confirm the environment logs to check if the web service call is hitting the service tier.
     
     
     
    7. Alternative:
    Add a temporary ERROR('Debug point'); statement in the codeunit to force a break and check if that triggers the debugger.
     
     
     
    Mark the checkbox below if this answers your question.
     
     
  • Suggested answer
    Hein Kruger Profile Picture
    629 on at
    Check your User/' Microsoft Entra Application Permissions in BC:
    There is "D365 Attach BUG " permissiion that you need to add. 


    If you are using a Microsoft Entra Applicaton - add the username in your Launch Json

     
     {
                "name": "Attach: Microsoft cloud sandbox",
                "type": "al",
                "request": "attach",
                "environmentType": "Sandbox",
                "environmentName": "UAT",
                "breakOnError": "All",
                "breakOnRecordWrite": "None",
                "enableSqlInformationDebugger": true,
                "enableLongRunningSqlStatements": true,
                "longRunningSqlStatementsThreshold": 500,
                "numberOfSqlStatements": 10,
                "tenant": "***************************",
                "breakOnNext": "WebServiceClient",
                 ******"userId": "User Name"****************
            }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,238

#2
YUN ZHU Profile Picture

YUN ZHU 773 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 630

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans