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

Calling Business Central SOAP Web Service using .NET

(0) ShareShare
ReportReport
Posted on by 170

Hi Everyone,

I am trying to call Business Central SOAP web service using the .NET code. i am able to do it with Business Central 15 online. However, it is not working with BC 16 online. 

URL is working fine with browser or SOAP UI, but, while accessing it using the .NET code, it is giving below error.

Connection to Business Central Failed System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

Below is my piece of code for reference.

updatebacktoeventrecord.Url = str;

updatebacktoeventrecord.UseDefaultCredentials = false;
updatebacktoeventrecord.Credentials = new System.Net.NetworkCredential(txtBCWebUser.Text, txtBCWebServiceKey.Password.ToString()); 
NAVConnector_Service service = new NAVConnector_Service();

if (updatebacktoeventrecord.WebServicesRunning() == 0)  //Error occurred here. WebServicesRunning is a procedure in Codeunit published as Web Service.
{
lbl_Error_Information.Visibility = System.Windows.Visibility.Visible;
lbl_Error_Information.Content = resourceDictionary["Conn50"].ToString();
lbl_Error_Information.Background = brush;
lblBaseServiceName.Content = "";
if (Directory.Exists(logpath))
{
WriteToFile("Connection to Business Central Failed due to web service setup in Business Central ", logpath.ToString());
}
return false;
}
else
{
if (Directory.Exists(logpath)) { WriteToFile("Connection to Business Central Succeeded ", logpath.ToString()); }
return true;
}

could anyone suggest what is the issue?? same code is working with Business Central 15.

Thanks in Advance.

  • Suggested answer
    Gearoid Profile Picture
    Gearoid on at
    RE: Calling Business Central SOAP Web Service using .NET

    Hi Sunil,

    This can be caused by a timeout. In any case, I would recommend opening a support ticket with Microsoft via your Solution Provider or Business Central Partner. 

    Hope that helps.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,403 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans