WCF-SQL Adapter: Connecting to the LOB system has failed. A network-related or instance-specific error occurred while establishing a connection to SQL Server

WCF-SQL Adapter: Connecting to the LOB system has failed. A network-related or instance-specific error occurred while establishing a connection to SQL Server

I been delivering a lot of BizTalk Server Training Courses for Developers and for Administrator in the past years that I normally like to call them “Developing BizTalk Server version Course” or “BizTalk Server Operations, Administration, and Maintenance (OAM) course” – yes I know, I am very creative in terms of names – and one of the good things about using Azure Virtual Machines for that is that we can easily create several developer machines in a short period of time and manage them for not consuming resources. And normally on of the task that is present in both courses is to configure BizTalk Server environment, because I believe that all BizTalk Developers should know the basics of BizTalk Server in terms of installation, configuration and optimizations – tasks that are normally done by BizTalk Administrations – I can go further and say that, in my personal opinion, if you don’t know these basic concepts you are not truly a BizTalk Developer because many things can be done by configurations and not code.

One of these tasks is to install and configure BizTalk Server LOB adapters, in especially SQL Server adapter, since in a Developer standalone machine we will need to have SQL Server, so it is easy to test this LOB Adapter. However, if we create the Azure BizTalk Server 2016 Developer machine, configure BizTalk Server and then install and configure LOB adapters without doing anything more and you try to create a BizTalk Server solution using Visual Studio and generate SQL Server schemas:

  • In the Solution Explorer, right-click your project, click “Add”, and then click “Add Generated Items…”
  • In the “Add Generated Items – <Project Name> dialog box, select “Consume Add Service”, and then click “Add”.
  • Select the sqlBinding and properly configuring the URI

We will get the following error message:

Connecting to the LOB system has failed.

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 – The remote computer refused the network connection.).

Connecting to the LOB system has failed: WCF-SQL Adapter

when we try to connect to the SQL Server configured.

Cause

This error may occur for several reasons like BizTalk Server cannot communicate with SQL Server machine because some firewall restrictions or SQL Server does not accept Remote Connections and so on.

However, in our case, we are talking about a standalone BizTalk machine that is trying to access a database in the local SQL Server.

Our problem was that by default what Microsoft could possibly configure wrong in terms of SQL Server protocols on the BizTalk Server developer image on Azure… is actually set up wrongly!

Connecting to the LOB system has failed: SQL Server 2016 Configuration Manager protocols

And as I described in my BizTalk Server Installation and configuration tutorial (see here), one of the important steps is to configure SQL Server Network Protocols, in special ensuring that TCP/IP is enabled and Shared Memory is disabled. You can see how to accomplish this using SQL Server Configuration Manager tool here.

The actual problem that was causing the connecting to fail while trying to connect to the LOB system, in this particular case the SQL Server is because the TCP/IP protocol is disabled.

Solution

To properly configure the protocols for SQL Server, especially the TCP/IP protocol, you should:

  • Press the “Windows key” to switch to Metro UI and type “SQL Server 20016 Configuration Manager” and click on “SQL Server 2016 Configuration Manager” option on Apps menu.
  • In SQL Server Configuration Manager windows, from the left-hand pane expand “SQL Server Network Configuration” option and then click “Protocols for MSSQLSERVER”
  • Verify that both “TCP/IP” and “Named Pipes” are enabled;
  • If not, right-click in the protocol, and then click “Enable”
  • Repeat to enable the other protocol if necessary.
  • Verify that “Shared Memory” is Disable.
  • If not, right-click Shared Memory, and then click “Disable”
  • In the left-hand pane, click “SQL Server Services”, right-click “SQL Server (MSSQLSERVER)”, and then click “Restart”.

Connecting to the LOB system has failed: SQL Server 2016 restart

  • Close SQL Server Configuration Manager.
  • Click “OK” and then “Apply”

After correctly configure the SQL Server protocols, again, especially the TCP/IP, you will be able to successfully connect and generate the SQL Server Schemas that you need for your BizTalk Server Solution.

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community. View all posts by Sandro Pereira

Consume Adapter Service option is missing from Add Generated Items in Visual Studio

Consume Adapter Service option is missing from Add Generated Items in Visual Studio

The Consume Adapter Service option from “Add Generated Items…” inside Visual Studio is metadata generation tool (or add-in), included in WCF LOB Adapter SDK, that can be used with BizTalk Projects to allow BizTalk developers to search or browse metadata from LOB adapters and then generate XML Schemas for selected operations inside Visual Studio.

This is a simple sample of the Consume Adapter Service tool to generate XML Schemas for SQL Server operations:

Consume Adapter Service tool SQL Server sample

However, recently while I was working in a client development environment with the LOB adapters installed and configured in the environment I notice that the Consume Adapter Service option was missing from “Add Generated Items…” window in Visual Studio

Consume Adapter Service option missing from Visual Studio

Cause

In our case, indeed we had the LOB adapters installed and configured in the environment, however, we only had the runtime of the WCF LOB Adapter SDK installed, in other words, we didn’t have the WCF LOB Adapter SDK fully installed.

The Consume Adapter Service tool will only be available in your Visual Studio if you install the Tools options from the WCF LOB Adapter SDK. This option will include the Adapter Code Generation Wizard and Visual Studio Addin Components.

Consume Adapter Service: WCF LOB Adapter SDK Tools option

Note: Personally, I recommend that you perform a full installation (all components) of the WCF LOB Adapter SDK on BizTalk Server Development environments.

Solution

The solution it is easy for this particular case, you just need to install the WCF LOB Adapter SDK Tools.

To install the WCF LOB Adapter SDK Tools you need:

  • Close any programs you have open. Run the BizTalk Server <version> installer as Administrator.
  • On the Start page, click “Install Microsoft BizTalk Adapters”
  • In the BizTalk Adapter Pack Start page, select the first step “Step 1. Install Microsoft WCF LOB Adapter SDK”. An installer of SDK is launched.
    • On the “Welcome to the Windows Communication Foundation LOB adapter SDK Setup Wizard” page, click “Next”
    • On the “Change, repair, or remove installation” page, select the “Change” option

 Consume Adapter Service: Change WCF LOB Adapter SDK installation

    • On the “Custom Setup” page, make sure that you select the option “Tools” to be installed and click “Next”

Consume Adapter Service: WCF LOB Adapter SDK Tools option

Note: Again, I personally recommend that you perform a full installation (all components) of the WCF LOB Adapter SDK on BizTalk Server Development environments.

    • On the “Ready to change Windows Communication Foundation LOB Adapter SDK Setup” page, click “Change” to begin the installation

Consume Adapter Service: confirm change WCF LOB Adapter SDK installation

After the installation is finished, if you open your BizTalk project solution once again in Visual Studio, you will see that the Consume Adapter Service option will now be available in the “Add Generate Items” window:

  • In Visual Studio, in the Project pane, right-click your BizTalk Server project, and then choose Add Add Generated Items… | Consume Adapter Service.

Consume Adapter Service present in Visual Studio

This problem can happen and the solution is the same for all BizTalk Versions (that contains LOB Adapters).

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community. View all posts by Sandro Pereira