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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

SOAP Exception Business Central 16

(0) ShareShare
ReportReport
Posted on by 7
We encountered the following issue before and it was fixed by Microsoft.
The discussion that saved our butts: https://forum.mibuso.com/discussion/comment/328902
However, the same message has popped up with Business Central 16. 
System.ObjectDisposedException
Message: Message is closed.
StackTrace:      
at System.ServiceModel.Channels.BufferedMessage.get_Headers()     
at Microsoft.Dynamics.Nav.Diagnostic.ServiceCallCorrelationProvider.GetCorrelationId[T](CorrelationIdType type)      
at Microsoft.Dynamics.Nav.Runtime.NavCurrentThread.get_GatewayCorrelationId()     
at Microsoft.Dynamics.Nav.Service.SOAP.ServiceDiagnosticState..ctor()      
at Microsoft.Dynamics.Nav.Service.SOAP.ServiceDiagnosticState..ctor(OperationContext context)      at Microsoft.Dynamics.Nav.Service.SOAP.NavWebService.ProcessMessage(Message message)     
at SyncInvokeProcessMessage(Object , Object[] , Object[] )      
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)      
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)      
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)      
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)      
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet) Source: System.ServiceModel HResult: -2146232798 StackTrace:      
at System.ServiceModel.Channels.BufferedMessage.get_Headers()      
at Microsoft.Dynamics.Nav.Diagnostic.ServiceCallCorrelationProvider.GetCorrelationId[T](CorrelationIdType type)     
at Microsoft.Dynamics.Nav.Runtime.NavCurrentThread.get_GatewayCorrelationId()     
at Microsoft.Dynamics.Nav.Service.SOAP.ServiceDiagnosticState..ctor()     
at Microsoft.Dynamics.Nav.Service.SOAP.ServiceDiagnosticState..ctor(OperationContext context)     
at Microsoft.Dynamics.Nav.Service.SOAP.NavWebService.ProcessMessage(Message message)     
at SyncInvokeProcessMessage(Object , Object[] , Object[] )      at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)     
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)      
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)      
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)      
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)  
Am I missing anything here? Has the error returned and what can we do about it?
I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    Wheh this exceotion happens? What SOAP ws are you calling?

  • hbulens Profile Picture
    7 on at

    I am not a BC expert so bear with me. It is a custom web service which is exposed through a page's functions. It is called from a .NET worker service:

    using (nav.Appointment_Service appointmentService = CreateAppointmentService())
    {
    appointmentService.Create(ref navAppointment);
    appointmentService.ProcessAppointment(navAppointment.Key);
    }

    Here is part of the WSDL:

    schemas.xmlsoap.org/.../">
    
    www.w3.org/.../XMLSchema">
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    schemas.xmlsoap.org/.../http" xmlns="">schemas.xmlsoap.org/.../" />
    
    codeunit xxx "Dime DS Handle Appointment"
    {
        TableNo = "Dime DS Appointment";
    
        trigger OnRun()
        var
            DSSourceType: Record "Dime DS Source Type";
            MissingSetupErr: Label 'Dime.Scheduler Source Type Setup for code %1 is missing';
        begin
            DSSourceType.SetRange("Source Type", "Source Type");
            DSSourceType.SetFilter("Processing Codeunit No.", '<>%1', 0);
            if not DSSourceType.FindFirst() then
                Error(MissingSetupErr, "Source Type")
            else
                CODEUNIT.Run(DSSourceType."Processing Codeunit No.", Rec);
        end;
    
        procedure ProcessAppointment(DSAppointment: Record "Dime DS Appointment")
        var
            DSHandleAppointment: Codeunit "Dime DS Handle Appointment";
        begin
            with DSAppointment do begin
                if not DSHandleAppointment.Run(DSAppointment) then begin
                    Status := Status::Error;
                    "Error Message" := CopyStr(GetLastErrorText(), 1, 250);
                end else begin
                    Status := Status::Processed;
                    "Error Message" := '';
                end;
                Modify(true);
            end;
    
            Commit();
        end;
    }
    I am fresh out of ideas where to look next. Any chance you happen to know where the problem may be?
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    SOAP web services are working correctly. I think here the problem is on your side. If this is a Visual Studio project, check if you've added the WS reference as a standard SOAP web service and not as a WCF service.

  • hbulens Profile Picture
    7 on at

    Thanks for the reply. Usually I would make the same comment as it's almost always the cause of the problem but this time I'd say it's the other way around. We've only had two cases in the last five years and both have been reported last week. The web reference hasn't been modified in donkey's years. One case was solved by bumping up the amount of cores on the BC server but this hasn't worked with the other case.

  • SylvainR Profile Picture
    5 on at

    We have the same exact behavior on BC 16. It is fairly easy to reproduce the problem by invoking any published web service and doing F5 and the message closed error will appear about 1 time on 3 or 4. It turned out that changing the number of virtual CPU core from 2 to 4 seems to have corrected the issue... what do you know?

  • Neal Carter Profile Picture
    35 on at

    Hi, we have the same problem after an automatic .NET4.8 update last night. We are using Jet Reports via SOAP - ironic thing is that the prod instance does not work yet the test one does, on the same box.

    So maybe change the VM cores?!?

  • hbulens Profile Picture
    7 on at

    Yes that's what we did/do when this problem comes up with our customers. I read somewhere that MS is not going to address this issue so bumping up the amount of cores would be the recommended course of action.

  • Verified answer
    Neal Carter Profile Picture
    35 on at

    Well, after a restart of the instance, all was well again. Really strange, perhaps a transient/timing issue when the services started, etc.

    I'll leave the cores unless it starts maxing out. I have noticed that BC certainly does need a lot of resource for on-prem deployments.

  • 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 June Top 10 Community Leaders

    These are the community rock stars!

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

    #1
    OussamaSabbouh Profile Picture

    OussamaSabbouh 653 Super User 2026 Season 1

    #2
    Gerardo Rentería García Profile Picture

    Gerardo Rentería Ga... 414 Most Valuable Professional

    #3
    YUN ZHU Profile Picture

    YUN ZHU 394 Super User 2026 Season 1

    Last 30 days Overall leaderboard

    Featured topics

    Microsoft Training Manuals

    Product updates

    Dynamics 365 release plans