tags:

views:

485

answers:

1

I am trying to create my own application definition xml file for the SharePoint BDC, mostly because I want to become more familiar with the concepts. My application uses an in-house Oracle database, and it contains only one entity which is intended to just retrieve a subset of columns from a single database table. The entity ("Analytical Spectra") contains just one Finder method with one input parameter which is also used as a filter.

Here's my entity:

<Entity EstimatedInstanceCount="0" Name="CHEMREG.CHEMREG_SPECTRA" DefaultDisplayName="Analytical Spectra">
  <Identifiers>
    <Identifier TypeName="System.Decimal" Name="SPECTRA_ID" DefaultDisplayName="SPECTRA_ID" />
  </Identifiers>
  <Methods>
    <Method Name="GetSpectra">
      <Properties>
        <Property Name="RdbCommandText" Type="System.String">SELECT SPECTRA_ID,
                                                                    BATCH_ID,
                                                                    CREATED_BY,
                                                                    CREATED_DATE,
                                                                    FILE_NAME,
                                                                    COMMENTS,
                                                                    NOTEBOOK_REF,
                                                                    FINAL,
                                                                    PDF_PATH,
                                                                    CHEMIST 
                                                             FROM CHEMREG.CHEMREG_SPECTRA
                                                             WHERE NOTEBOOK_REF LIKE :Notebook_Ref                                                                       
        </Property>
        <Property Name="RdbCommandType" Type="System.Data.CommandType">Text</Property>
      </Properties>
      <FilterDescriptors>
        <FilterDescriptor Type="Wildcard" Name="Notebook Ref" />
      </FilterDescriptors>
      <Parameters>
        <Parameter Direction="In" Name=":Notebook_Ref">
          <TypeDescriptor TypeName="System.String"
                          Name="NOTEBOOK_REF"
                          AssociatedFilter="Notebook Ref">
          </TypeDescriptor>
        </Parameter>
        <Parameter Direction="Return" Name="CHEMREG_SPECTRA">
          <TypeDescriptor TypeName="System.Data.IDataReader, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" IsCollection="true" Name="CHEMREG_SPECTRADataReader">
            <TypeDescriptors>
              <TypeDescriptor TypeName="System.Data.IDataRecord, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="CHEMREG_SPECTRADataRecord">
                <TypeDescriptors>
                  <TypeDescriptor TypeName="System.Decimal" Name="SPECTRA_ID" IdentifierName="SPECTRA_ID" DefaultDisplayName="Spectra ID" />
                  <TypeDescriptor TypeName="System.String" Name="BATCH_ID" DefaultDisplayName="Batch ID" />
                  <TypeDescriptor TypeName="System.String" Name="CREATED_BY" DefaultDisplayName="Created By"/>
                  <TypeDescriptor TypeName="System.String" Name="CREATED_DATE" DefaultDisplayName="Created Date" />
                  <TypeDescriptor TypeName="System.String" Name="FILE_NAME" DefaultDisplayName="File Name" />
                  <TypeDescriptor TypeName="System.String" Name="COMMENTS" DefaultDisplayName="Comments" />
                  <TypeDescriptor TypeName="System.String" Name="NOTEBOOK_REF" AssociatedFilter="Notebook Ref" DefaultDisplayName="Notebook Ref" />
                  <TypeDescriptor TypeName="System.Decimal" Name="FINAL" DefaultDisplayName="Final" />
                  <TypeDescriptor TypeName="System.String" Name="PDF_PATH" DefaultDisplayName="PDF Path" />
                  <TypeDescriptor TypeName="System.String" Name="CHEMIST" DefaultDisplayName="Chemist" />
                </TypeDescriptors>
              </TypeDescriptor>
            </TypeDescriptors>
          </TypeDescriptor>
        </Parameter>
      </Parameters>
      <MethodInstances>
        <MethodInstance Name="CHEMREG_SPECTRAFinder" Type="Finder" ReturnParameterName="CHEMREG_SPECTRA" ReturnTypeDescriptorName="CHEMREG_SPECTRADataReader" ReturnTypeDescriptorLevel="0" />
      </MethodInstances>
    </Method>
  </Methods>
</Entity>

My application can be uploaded into the BDC just fine (with the warning that the SpecificFinder couldn't be found, but I didn't think that was a big deal here... is it?). When I add a Business Data List Web Part to a page and choose my "Analytical Spectra" entity for display, I get an error in the UI that says:

An error occurred while retrieving data from Analytical Spectra. Administrators, see the server log for more information.

The server log contains this information, which I find confusing:

Error while instantiating Filter Type: Microsoft.Office.Server.ApplicationRegistry.Runtime.WildcardFilter ... Inner exception 1: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Cannot create default instance on a Parameter with DirectionType 'Out', 'Return' or 'SqlReturn'

I am confused by this because it seems to be complaining about a filter on my return parameter, and I haven't defined a filter on my return parameter. What am I screwing up?

+1  A: 

Ah, ha. The problem was this entry in the return type definition:

<TypeDescriptor TypeName="System.String" 
                Name="NOTEBOOK_REF" 
                AssociatedFilter="Notebook Ref"
                DefaultDisplayName="Notebook Ref" />

The output type definition shouldn't refer to a filter. The type descriptor should instead have been:

<TypeDescriptor TypeName="System.String" 
                Name="NOTEBOOK_REF" 
                DefaultDisplayName="Notebook Ref" />

Works like a charm after making that change.

Chris Farmer