Thursday, April 24, 2008

Error with SharePoint BDC

I recently got the error :
"Application definition import failed. The following error occurred: The IdentifierName Attribute of the TypeDescriptor named 'FirstName' of the Parameter named '@FirstName' of the Method named 'GetCustomers' of the Entity named 'Customers' does not match any of the defined Identifiers for the Entity. Error was encountered at or just before Line: '57' and Position: '16'."
When trying to import a BDC schema into MOSS 2007.

It turned out that I'd forgotten to add the following line to the <Identifiers>
<Identifier Name="FirstName" TypeName="System.String" />

Following that fix I get the next error:
"Application definition import failed. The following error occurred: The AssociatedFilter Attribute of the TypeDescriptor named 'FirstdName' of the Parameter named '@FirstName' of the Method named 'GetCustomers' of the Entity named 'Customers' does not match any of the defined FilterDescriptors for the Method. Error was encountered at or just before Line: '57' and Position: '16'."

So I added the lines to the <FilterDescriptors> tag:
<FilterDescriptor Type="Wildcard" Name="FirstName" >
<Properties>
<Property Name="UsedForDisambiguation" Type="System.Boolean">true</Property>
</Properties>
</FilterDescriptor>

Following that, I got another error after successful installation of the schema into SharePoint when the User attempted to run the webpart. "The Business Data Catalog is configured incorrectly. Administrators, see the server log for more information.". That error is found within the Servers Event Log:
"A Metadata Exception was constructed in App Domain '/LM/W3SVC/1959965621/Root-2-128667808042048704'. The full exception text is: Could not find appropriate places on the root TypeDescriptor to read sub-identifier values for the Instance of Entity 'Customers'"

The fix for this was because I forgot to add the "IdentifierName="FirstName" to the TypeDescriptor tag.
<TypeDescriptor TypeName="System.String" IdentifierName="FirstName" Name="FirstName" >
<LocalizedDisplayNames>
<LocalizedDisplayName LCID="1033">FirstName</LocalizedDisplayName>
</LocalizedDisplayNames>
<Properties>
<Property Name="DisplayByDefault" Type="System.Boolean">true</Property>
</Properties>
</TypeDescriptor>

So the rule of the game when using the SharePoint BDC is watch your XML when adding new fields to a query..

Tuesday, April 15, 2008

Double Metaphone

Found a really nice search function which allows for "Sounds like" searchs in C#. It's called the Double Metaphone (http://en.wikipedia.org/wiki/Double_Metaphone
) which breaks the name down into a small 4 char fild which you can match.

The source code can be found from the CodeProject website (http://www.codeproject.com/KB/recipes/dmetaphone5.aspx). simply include this in you VS2005 project (it should convert without any issues).

using using nullpointer.Metaphone;
....
DoubleMetaphone mphone = new DoubleMetaphone(_surname);
string mphone_Surname = mphone.PrimaryKey;
....

Monday, April 7, 2008

WCF and BizTalk

Had a major problem with joining BizTalk to a WCF Server application today. There seemed to be very little information out there on the net regarding the very generic error I found in the Event Log:

Event Type: Warning
Event Source: BizTalk Server 2006
Event Category: BizTalk Server 2006
Event ID: 5743
Date: 7/04/2008
Time: 9:55:14 PM
User: N/A
Computer: IFUBUY
Description:
The adapter failed to transmit message going to send port "WcfSendPort_Service_WSHttpBinding_IService" with URL "http://localhost:1501/WCFService1/Service.svc". It will be retransmitted after the retry interval specified for this Send Port. Details:"System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. ---> System.ServiceModel.FaultException: The message could not be processed because the action '' is invalid or unrecognized.
--- End of inner exception stack trace ---

Server stack trace:
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndRequest(IAsyncResult result)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.ServiceModel.Channels.IRequestChannel.EndRequest(IAsyncResult result)
at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.RequestCallback(IAsyncResult result)".

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

After some time I found that the default bindings generated by the WCF BizTalk Wizard was incorrect (or at least not correct for a single test purpose).
<BtsActionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Operation Name="GetData" Action="http://tempuri.org/IService/GetData" />
<Operation Name="GetDataUsingDataContract" Action="http://tempuri.org/IService/GetDataUsingDataContract" />
</BtsActionMapping>

Should be replaced with simply
http://tempuri.org/IService/GetData

Now I've to figure out how to make it dynamic!

Saturday, April 5, 2008

WCF and WPF

Started investigations into the wonderful world of WCF and WPF today. Found two very interesting and well layed out books which could be of use to others.
Programming WCF, O'Reilly Press, ISBN 10: 0-596-52699-7
Programming WPF, O'Reilly Press, ISBN 10: 0-596-51037-3