Beispiel-BDC-Modell

Letzte Änderung: Donnerstag, 15. April 2010

Gilt für: SharePoint Server 2010

Das folgende Beispiel-BDC-Modell stellt einen externen Inhaltstyp "Kunde" für ein externes System vom Typ Webdienst dar. Das Beispiel, das den in SharePoint 2010 SDK enthaltenen Beispielwebdienst AdventureWorks verwendet, enthält Folgendes:

  • Hinzufügen eines einfachen externen Inhaltstyp WSCustomer mit einem Method-Objekt

  • Hinzufügen eines MethodInstance-Objekts, damit die Method zur Laufzeit ausführbar ist

  • Zuordnen von zwei externen Inhaltstypen, "Kunde" und "Bestellung"

Beispiel: Hinzufügen einer einfachen Entität mit einem "Method"-Objekt

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://schemas.microsoft.com/windows/2007/BusinessDataCatalog BDCMetadata.xsd" Name="AdventureWorksWSModel" IsCached="false" xmlns="https://schemas.microsoft.com/windows/2007/BusinessDataCatalog">
   <LobSystems>
    <LobSystem Type="Wcf" Name="AdventureWorksWS">
      <Properties>
        <Property Name="WsdlFetchAuthenticationMode" Type="System.String">PassThrough</Property>
        <Property Name="WcfMexDiscoMode" Type="System.String">Disco</Property>
        <Property Name="WcfMexDocumentUrl" Type="System.String">http://webserver:90/webservice.asmx?wsdl</Property>
        <Property Name="WcfProxyNamespace" Type="System.String">BCSServiceProxy</Property>
        <Property Name="WildcardCharacter" Type="System.String">*</Property>
      </Properties>
      <LobSystemInstances>
        <LobSystemInstance Name="AdventureWorksWS">
          <Properties>
            <Property Name="WcfAuthenticationMode" Type="System.String">PassThrough</Property>
            <Property Name="WcfEndpointAddress" Type="System.String">http://webserver:90/webservice.asmx</Property>
            <Property Name="ShowInSearchUI" Type="System.String"></Property>
          </Properties>
        </LobSystemInstance>
      </LobSystemInstances>
      <Entities>
        <Entity Namespace="AdventureWorks” Version="1.0.0.0" EstimatedInstanceCount="10000" Name="WSCustomer" DefaultDisplayName="WSCustomer">
          <Properties>
            <Property Name="OutlookItemType" Type="System.String">Contact</Property>
          </Properties>
          <Identifiers>
            <Identifier TypeName="System.Int32" Name="CustomerId" />
          </Identifiers>
          <Methods>
            <Method IsStatic="false" Name="GetCustomerById">
              <Parameters>
                <Parameter Direction="In" Name="customerId">
                  <TypeDescriptor TypeName="System.Int32" IdentifierName="CustomerId" Name="customerId" />
                </Parameter>
                <Parameter Direction="Return" Name="GetCustomerById">
                  <TypeDescriptor TypeName="BCSServiceProxy.SalesCustomer, AdventureWorksWS" Name="GetCustomerById">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="System.Int32" ReadOnly="true" IdentifierName="CustomerId" Name="CustomerId" />
                      <TypeDescriptor TypeName="System.String" Name="Title" />
                      <TypeDescriptor TypeName="System.String" Name="FirstName">
                        <Properties>
                          <Property Name="OfficeProperty" Type="System.String">FirstName</Property>
                        </Properties>
                      </TypeDescriptor>
                      <TypeDescriptor TypeName="System.String" Name="MiddleName" />
                      <TypeDescriptor TypeName="System.String" Name="LastName">
                        <Properties>
                          <Property Name="OfficeProperty" Type="System.String">LastName</Property>
                        </Properties>
                      </TypeDescriptor>
                      <TypeDescriptor TypeName="System.String" Name="EmailAddress" />
                      <TypeDescriptor TypeName="System.String" Name="Phone" />
                      <TypeDescriptor TypeName="System.DateTime" Name="ModifiedDate" />
                    </TypeDescriptors>
                  </TypeDescriptor>
                </Parameter>
              </Parameters>
              <MethodInstances>
                <!- See below>
              </MethodInstances>
            </Method>
          </Methods>
        </Entity>
      </Entities>
    </LobSystem>
  </LobSystems>
</Model>

Beispiel: Hinzufügen eines "MethodInstance"-Objekts, damit das "Method"-Objekt zur Laufzeit ausführbar ist

Im vorherigen Beispiel war das Method-Objekt zur Laufzeit nicht ausführbar. Im folgenden Codebeispiel wird erläutert, wie der vorherigen Entität "Kunde" ein MethodInstance-Objekt hinzugefügt wird, damit das Method-Objekt ausführbar ist.

<MethodInstances>
       <MethodInstance Type="SpecificFinder" ReturnParameterName="GetCustomerById" Default="true" Name="GetCustomerById" DefaultDisplayName="Read Item WSCustomer">
           <Properties>
             <Property Name="LastDesignedOfficeItemType" Type="System.String">Contact</Property>
           </Properties>
       </MethodInstance>
</MethodInstances>

Associating Two entities, Customer and Order

Die Zuordnung ist ein Typ eines MethodInstance-Objekts. Das folgende Codebeispiel zeigt die Zuordnung von zwei Entitäten. Es wird davon ausgegangen, dass ein weiterer Entitätstyp mit dem Namen Bestellung mit einer Methode, die einen Parameter mit dem Namen 'Orders zurückgibt, in dem Modell bereits definiert ist. Hier ordnet das Modell die beiden Entitäten "Kunde" und "Bestellung" zu.

<!—BDC has three types of association operations - AssociationNavigator, Associate and DisAssociate -->
<MethodInstances>
   <Association Name="GetOrdersByCustomer" Type="AssociationNavigator" ReturnParameterName="Orders">
<!—Name of the Source entity in the association -->
      <Source Name="Customer" Namespace="AdventureWorks">
      <!—Name of the destination entity in the association -->
<Destination Name="Order" Namespace=" AdventureWorks">
   </Association>
</MethodInstances>
HinweisHinweis

Um das Beispiel abzukürzen und fertigzustellen, werden die Objekte LobSystem und LobSystemInstance für den externen Inhaltstyp nicht dargestellt.

Die Dokumentation des BDC-Modellschemas finden Sie unter BDCMetadata-Schema, und unter Business Connectivity Services: XML-Beispieldateien und Codeausschnitte finden Sie weiter Beispiele.