BDC WebService and valid Return Types

Hi,

is there a list of valid return types for a Webservice Method ? I got a customer returning XmlDocuments. What would the BDC representation for this datatype be if it is possible to have such a return type at all ? I presume i have to dive into that XmlDocument on the BDC Site and define every Element and Attribute...

And what about having a simple Dataset ?

Any advice on this ?

Thanks,

Oliver

[446 byte] By [Vansen] at [2008-1-1]
# 1
Yes, you have to dive!!! and Dataset is not welcome and I would love to be wrong on this one.
FrankChiang at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Business Data Catalog...
# 2

Hi Frank,

thanks for the information. Could you provide a sample for a dataset ? Let's say a Dataset with one Table and one Column to keep it "simple" Wink Would appreciate any help on this. I know that using Datasets as return types is not best practice at all but it would be nice to have that kind of functionality to bypass converting the contents of a dataset to a Array of a typed Class..

Thanks,

Oliver

Vansen at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Business Data Catalog...
# 3

Hi Oliver,

Sorry that I caused your misunderstanding. When I said dataset is not welcome I meant BDC cannot deal with web service with dataset return type. So in practice when you create a web service and inside the web service you query the database and get a dataset back, you have to convert it into array of list(s) and send them out as the return parameter. This is a little more work but I think this is the way.

FrankChiang at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Business Data Catalog...
# 4

I am happy to be wrong on this one. I found this on MSDN, that means dataset returntype can be done.

<Parameter Direction="<b>Return</b>" Name="<b>Customers</b>"> <TypeDescriptor Name=""DataSet"" TypeName=""System.Data.DataSet, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089""> <TypeDescriptors> <TypeDescriptor Name=""Tables"" TypeName=""System.Data.DataTableCollection, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" IsCollection=""true""> <TypeDescriptors> <TypeDescriptor Name=""Table"" TypeName=""System.Data.DataTable, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" > <TypeDescriptors>  <TypeDescriptor Name=""Rows"" TypeName=""System.Data.DataRowCollection, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" IsCollection=""true"">  <TypeDescriptors>  <TypeDescriptor Name=""DataRow"" TypeName=""System.Data.DataRow, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"">  <TypeDescriptors>  <TypeDescriptor Name=""field1"" TypeName=""System.String"" IdentifierName=""f1"" />  <TypeDescriptor Name=""field2"" TypeName=""System.String"" />  <TypeDescriptor Name=""field3"" TypeName=""System.String"" />  </TypeDescriptors>  </TypeDescriptor>  </TypeDescriptors>  </TypeDescriptor> </TypeDescriptors> </TypeDescriptor> </TypeDescriptors> </TypeDescriptor> </TypeDescriptors> </TypeDescriptor> </Parameter> 
FrankChiang at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Business Data Catalog...
# 5

Isn't that application definition file for a database rather than a web service? That doesn't mean it's not possible to return a dataset via a web service of course.

Sorry I realised after typing it of course it's from a web service. A database would just return direct columns.

I would say that returning datasets as the return parameter is bad practise though as it ties the web services to only being a .net language that can call it. ie if you wanted to use it in a Java client in a years time it would struggle. Better to return your own objects made up of strings, ints, etc, or an array of your own objects.

NickSwan at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Business Data Catalog...
# 6

Thanks guys for your help,

always appreciate your help...

Vansen at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Business Data Catalog...
# 7

Dear frds,

Can we configure search on web service based BDC which is returning dataset? I dont think that we can index DataTableCollection as it supports multilpe indexers. Is it right? If not then kindly let me know how we can configure search on a web service returning dataset.

Thanx in advance,

Akif

Akif at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Business Data Catalog...
# 8
Does anyone have a real world example of this dataset TypeDescriptor. For instance, how does it know which DataTable to use in the collection to get to the DataRow?
dflynn12 at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Business Data Catalog...
# 9

Hi dflynn12,

as mentioned above just returning a Dataset from a Webservice isn't good practice. The Problem is that when you are returning a dataset you have to know the structure inside of it - the webservice can't tell you about that. On the other hand you have to make sure that the internal structure of the Dataset that gets returned by the webservice doesn't ever change - Thats why it is bad practice...

As far as i know there is no way to examine the dataset at run-time and rewrite the BDC-xml according to the contents - That would really be cool...

Vansen at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Business Data Catalog...
# 10

Man here you go Smile

<Entity Name="RootCategory">

<Identifiers>

<Identifier Name="CategoryName" TypeName="System.String" />

</Identifiers>

<Methods>

<Method Name="GetRootCategories">

<Parameters>

<Parameter Direction="In" Name="language">

<TypeDescriptor TypeName="System.String" Name="language">

<DefaultValues>

<DefaultValue MethodInstanceName="CategorySpecificFinderInstance" Type="System.String">en-us</DefaultValue>

<DefaultValue MethodInstanceName="CategoryFinderInstance" Type="System.String">en-us</DefaultValue>

</DefaultValues>

</TypeDescriptor>

</Parameter>

<Parameter Direction="Return" Name="GetRootCategoriesResult">

<TypeDescriptor TypeName="Catalogs.ServiceDataSetContract, Catalogs" Name="GetRootCategoriesResult">

<TypeDescriptors>

<TypeDescriptor TypeName="System.Data.DataSet, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Value">

<TypeDescriptors>

<TypeDescriptor TypeName="System.Data.DataTableCollection, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Tables" IsCollection="true">

<TypeDescriptors>

<TypeDescriptor TypeName="System.Data.DataTable, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Categories">

<TypeDescriptors>

<TypeDescriptor TypeName="System.Data.DataRowCollection, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Rows" IsCollection="true">

<TypeDescriptors>

<TypeDescriptor TypeName="System.Data.DataRow, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Categories">

<TypeDescriptors>

<TypeDescriptor TypeName="System.String" IdentifierName="CategoryName" Name="CategoryName" >

<LocalizedDisplayNames>

<LocalizedDisplayName LCID="1033">CategoryName</LocalizedDisplayName>

</LocalizedDisplayNames>

</TypeDescriptor>

<TypeDescriptor TypeName="System.String" Name="DisplayName" >

<LocalizedDisplayNames>

<LocalizedDisplayName LCID="1033">Name</LocalizedDisplayName>

</LocalizedDisplayNames>

</TypeDescriptor>

</TypeDescriptors>

</TypeDescriptor>

</TypeDescriptors>

</TypeDescriptor>

</TypeDescriptors>

</TypeDescriptor>

</TypeDescriptors>

</TypeDescriptor>

</TypeDescriptors>

</TypeDescriptor>

</TypeDescriptors>

</TypeDescriptor>

</Parameter>

</Parameters>

<MethodInstances>

<MethodInstance Type="Finder" ReturnParameterName="GetRootCategoriesResult" ReturnTypeDescriptorName="GetRootCategoriesResult" ReturnTypeDescriptorLevel="0" Name="CategoryFinderInstance" />

<MethodInstance Type="SpecificFinder" ReturnParameterName="GetRootCategoriesResult" ReturnTypeDescriptorName="GetRootCategoriesResult" ReturnTypeDescriptorLevel="0" Name="CategorySpecificFinderInstance" />

</MethodInstances>

</Method>

</Methods>

</Entity>

I have used this definition my self and it is working but remember you cannot use out-of-box BDC controls for this. You need to develop your own controls for these.

Akif at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Business Data Catalog...

SharePoint Products and Technologies

Site Classified