Following yesterday’s blog post, on the same note, when we tried to generate a WCF-SQL stored procedure schema for a new BizTalk Server solution, we got the following error inside Visual Studio:
Error while retrieving or generating the WSDL. Adapter message: Retrieval of Operation Metadata has failed while building WSDL at ‘TypedProcedure/dbo/<stored-procedure-name>’
Once again, this is quite a generic error, and to gain more insight, you need to click on Details.
Microsoft.ServiceModel.Channels.Common.MetadataException: Retrieval of Operation Metadata has failed while building WSDL at ‘TypedProcedure/dbo/<stored-procedure-name>’ —> System.Data.SqlClient.SqlException: Invalid object name ‘table-name.column-name’.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
Cause
This error normally tells you that something is broken inside your stored procedure. In other words, your stored procedure is not working properly, and it gives an error while you execute it.
In my case, the stored procedure was doing an inner join with a table that belonged to another database, and someone forgot to reference that database, something like [database-name].[table-name].[column-name].
Solution
Solving this issue is quite simple:
- Open SQL Server Management Studio (SSMS) and execute the stored procedure you want to use to generate the schema.
- Check what the error is on the output window and fix it..
- Repeat this process until you are able to successfully execute the stored procedure.
After doing that, I was able to successfully generate the SQL schema for that stored procedure.
Hope you find this helpful! So, if you liked the content or found it useful and want to help me write more, you can buy (or help me buy) my son a Star Wars Lego!