Configuring a LOB WebService in Sharepoint 2007 – The Easier Way,Part 2

To continue Part 1 here is this weeks entry
The first stage is to describe the connection to the Web Service with an XML file adhering to a schema file.
The best way to create an XML file is to take the schema file and point to it in your VisualStudio file properties. This way you get AutoComplete and syntax check to your XML file.
To do so in our case you will have to either point the schema to the \Program Files\Microsoft Office Server\12.0\Bin\bdcmetadata.xsd file on the server. Or copy it to a folder in your local machine and run it. I am providing it from my site here bdcmetadata.txt (you need to edit its extention back to XSD).
So now that you set up your visual studio and can begin editing the XML start by copying this XML snippet
(Remember to remove the space between the Microsoft.com and the rest of the URI)
<lobsystem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.microsoft.com
/office/2006/03/BusinessDataCatalog/BDCMetadata.xsd" Type="WebService" Version="1.0.0.0" Name="[Arbitrary Name]" xmlns="http://schemas.microsoft.com
/office/2006/03/BusinessDataCatalog"> <properties> <property Name="WebServiceProxyNamespace" Type="System.String"> [Arbitrary Name Matching the name attribute at the root element] </property> <property Name="WildcardCharacter" Type="System.String">%</property> <property Name="WsdlFetchAuthenticationMode" Type="System.String"> PassThrough </property> <property Name="WsdlFetchUrl" Type="System.String"> [WSDL path (URI) for the webservice]</property> </properties> Ķ </lobsystem>
Replace the [] with the accurate data.
Next you need to define the instance of the LOB System. In SQL connection this is the area where you will define the connection string and authentication.
In the webservice this is more like an identifier for the SharePoint to hold on to.
<lobsysteminstances> <lobsysteminstance Name="[Arbitrary Name Matching the name attribute at the root element]"> <properties> <property Name="WebServiceAuthenticationMode" Type="System.String">PassThrough</property> </properties> </lobsysteminstance> </lobsysteminstances>
Before you continue you need to know the schema of your data returned from the WebService in order to describe it in your XML.
The main part of the call to the Web Service is to be able to define the connections.
The way it is achived is these tags:
<entities> – Container for Entity.
<entity EstimatedInstanceCount="12345" Name=" "> – Entities contain identifiers, methods, and actions. Entities can also have other related entities associated with them. Entities represent a displayable instance in the SharePoint Data catalog that is searchable. An entity is consumable from data catalog webparts.

<identifiers> <identifier Name="GetChannel" TypeName="System.String" /> </identifiers>
Identifier is the main searchable key that is related to the entity.
Next is the method and parameters.
The method is the root of a WebService exposed parameter.
You define its name as the name of the method in the WSDL.
<method Name="[As defined in the WSDL]">
Each method holds parameters.
<parameters>
Each parameter has a direction:
In – Business Data Catalog initializes the parameter and passes it to the system.
Out – like C# out keyword you pass a parameter from the MOSS to get the value back.
InOut Like ref keyword in C#.
Return – The system initializes the parameter and passes it to the Business Data Catalog as the return value of a method.
<parameter Direction="In" Name="[Just a Token you can name it arbitrary]"> <typedescriptor TypeName="System.String" IdentifierName="[Must match the structure]" Name="[Arbitrary]" /> </parameter>
For complex types you have another way to create the parameter.
You have to figure out the structure of your type from the WSDL (or if you built it then you already know).
Lets say its an array of rows in a table each row containing name and address.
This is the structure you will need to create with the Type Descriptors:
<parameter Direction="Return" Name="Get_ChannelsResponse"> <typedescriptor TypeName="Proxy.OutTable[],Proxy" IsCollection="true" Name="OutTableArray"> <typedescriptors> <typedescriptor TypeName="Proxy.OutTable, Proxy" IsCollection="false" Name="OutTable"> <typedescriptors> <typedescriptor TypeName="System.String" Name="name"> </typedescriptor> <typedescriptor TypeName="System.String" Name="address"> </typedescriptor> </typedescriptors> </typedescriptor> </typedescriptors> </typedescriptor> </parameter>
You see the drill down of the parameter to get the final types in the table.
The schema representing this array is this:
<complextype name="OutTable"> <sequence> <element name="name" nillable="true" type="xsd:string"/> <element name=" address " nillable="true" minOccurs="0" type="xsd:string"/> </sequence> </complextype> <complextype name="Get_ChannelsResponse"> <sequence> <element name="OutTable" nillable="true" type="impl:OutTableArray"/> </sequence> </complextype> <complextype name="OutTableArray"> <complexcontent> <restriction base="soapenc:Array"> <attribute ref="soapenc:arrayType" wsdl:arrayType="impl:OutTable[]"/> </restriction> </complexcontent> </complextype>

The next stage of the session will be the creation of the Application in the back end of the system.

Some resources you can get help from are:
The business Data Catalog section in MSDN 2

The members list of the XML schema in MSDN 2

Comments

  1. Jonathan says:

    Hi, Thanks for posting the link.

    I’m trying to create my own BDC XML MetaData. I can create it successfully via code. When trying to add a Web Part using the BDC Application I’m getting the following error: ” The LobSystem/LobSystemInstance Property ‘WebServiceAuthenticationMode’ has an invalid value (or type) ‘Pass Through'” I have tried, PassThrough,
    RevertToSelf, Credentials, and WindowsCredentials all with the same error except for the type.
    Do you have any ideas as to what I’m doing wrong?
    I am doing this for a webservice and not for a SQL database.

Speak Your Mind

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.