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!