Error message when you use the Import-SPBusinessDataCatalogModel PowerShell cmdlet to retrieve the WSDL Business Data Catalog: "Proxy creation failed. Default context not found"

Article translations Article translations
Article ID: 983018 - View products that this article applies to.
Expand all | Collapse all


Consider the following scenario:

You have a server that is running Microsoft SharePoint Server 2010 with Enterprise Client Access License (CAL) enabled. You use the following Windows PowerShell cmdlet to fetch the Web Services Description Language (WSDL) Business Data Catalog of the line-of-business (LOB) system: 
In this scenario, you receive the following error message:

Import-SPBusinessDataCatalogModel : Proxy creation failed. Default context not found.
Error was encountered at or just before Line: 'line#' and Position: 'position#'.
At line:line# char:char#
+ Import-SPBusinessDataCatalogModel <<<< -Identity $catalog -Path path_to_catalog\linkus.bdcm
+ CategoryInfo : InvalidData: (Microsoft.Share...alogModelCmdlet: SPImportSPBusinessDataCatalogModelCmdlet) [Import-SPBusinessDataCatalogModel], PackageFormatException
+ FullyQualifiedErrorId : Microsoft.SharePoint.BusinessData.SharedService.SPImportSPBusinessDataCatalogModelCmdlet


This issue occurs when the ServiceContext scope is not defined before you try to import the WSDL Business Data Catalog.


Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure. However, they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

To work around this issue, you must define the ServiceContext scope before you try to use the Import-SPBusinessDataCatalogModel Windows PowerShell cmdlet. The following is an example Windows PowerShell script that implements this workaround: 
$ctx = Get-SPServiceContext http://localhost

$catalog = Get-SPBusinessDataCatalogMetadataObject -BdcObjectType catalog -ServiceContext $ctx

$scope = new-object Microsoft.SharePoint.SPServiceContextScope $ctx; Import-SPBusinessDataCatalogModel -Identity $catalog -Path \\path_to_catalog\linkus.bdcm; $scope.Dispose()
To programmatically set the scope, you must use the following declarations:
SPServiceContextScope scope = null;
if (SPServiceContext.Current == null)


scope = new SPServiceContextScope(context);

When the code finishes the import, you must dispose the scope as follows:


For more information about how to set the scope for Business Data Catalog imports, visit the following SharePoint blog page:
SharePoint+PowerShell is (Usually) a Perfect Match


Article ID: 983018 - Last Review: April 9, 2011 - Revision: 2.0
  • Microsoft SharePoint Server 2010
kbprb kbsurveynew kbpubtypekc kbexpertiseadvanced kbcodefx kbscript KB983018

Give Feedback


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from