How handling error adapter WCF

I’m working with a custom WCF adapter, and now we get some issue when pipeline failed validation : here is the MSDN explanation to handle it

For a receive location, you can configure one of two error handling options under the Error Handling section on the Messages tab in the Transport Properties dialog box.

If the Suspend request message on failure option is selected, the incoming request message will be suspended should there be a processing failure in the receive pipeline or a failure in the routing of the message. This allows the sender of the message to succeed in their transmission to BizTalk Server and receive an acknowledgment (ACK) message. BizTalk Server will suspend the message and record a complete error record for the failed message. However, it also does not send the message exception back to the sender in this case. This applies to one-way ports only and will send an ACK if checked, and if unchecked will send a NACK. For two-way ports, if processing fails, BizTalk will always receive a NACK.

However, if the client needs to have access to the failed exception, select the Include exception details in faults option. When selected, this returns a SOAP fault to the caller if a processing error occurs. This is the same as specifying the serviceDebug behavior with “IncludeExceptionDetailsInFaults” to True on the Behavior tab of the WCF-Custom or WCF-CustomIsolated adapters. The detailed exception is now sent to the client. This option is more practical and safer to use during development of an application than in production because the internal fault messages most likely should not be sent to callers of the service.

For the two-way send port, you can choose whether to forward SOAP fault messages on to the original caller over a solicit-response send port by selecting Propagate fault message. If this option is not selected, BizTalk Server will generate a NACK first, and then suspend the message. If it is selected, BizTalk Server will treat the message as a valid WCF response message from the external service and the response message will not be suspended because it is propagated.

WCF-SQL and XML parameter

WCF-SQL can be used with a Stored Procedure that has an XML parameter.

The Xml parameter is converted in a string parameter in the generated code. So for passing an XML, you need to convert it in string with encoding.

It exists a simpler manner :

  • In your orchestration, only create your XML parameter as a message
  • Send it via your send port to WCF-SQL
  • Now in the send port click on configure
  • Click the Messages tab, and in the Outbound WCF message body section, choose the Template option.
  • In the XML text box, specify the template that will be used to construct the WCF message. By doing so, you create a message that conforms to the operation for the WCF-based SQL adapter
  • For the ADD_LAST_EMP_XML_INFO stored procedure, you must specify the following template:
    <ADD_LAST_EMP_XML_INFO xmlns="">
    <bts-msg-body xmlns="" encoding="string"/> </xml_info>
  • The Tag encoding is very important. By specifying string, it’ll replace <> and other special caracter by their encoding (like &gt; …)

This method  is very powerfull, the only problem is you need to ensure that your schema is up to date manually

For more information see MSDN :

Monitoring WCF service with AppFabric

With AppFabric you can monitor your WCF services.

You’ve got two ways for this :

The first one by editing the config file,

Add this section :


      <default enabled="true" connectionStringName="DefaultApplicationServerExtensions" monitoringLevel="Troubleshooting" /> 

The connectionStringName attribute should contain a reference to an existing connection string in the ConnectionString section, and that’s the database used by AppFabric to store the monitoring events.

The monitoringLevel attribute specifies the number of events you want to capture in a service execution. The possible values for this setting are,

  • Off (monitoringLevel= »Off”): No data is collected. It would be equivalent to have monitoring disabled.
  • Errors only (monitoringLevel= »ErrorsOnly”):  Only errors and warnings events are collected. This is very useful when you don’t want to incur into performance issues for collecting application events but you still want to know about any error may happen during the execution.
  • Health Monitoring (monitoringLevel=HealthMonitoring): This is the default level and collects enough application events to show different metrics in the AppFabric dashboard.
  • End To End Monitoring (monitoringLevel= »EndToEndMonitoring”). It collects all the events from the Health Monitoring level, plus additional events to reconstruct the message flow. For example, Service A called Service B. You will get also events representing info about the Service B call if monitoring is enabled on Service A.
  • Troubleshooting (monitoringLevel= »Troubleshooting »). This is the most verbose of all, so it is appropriate for troubleshooting an unhealthy application.

The second way is more friendly use :

  1. Start or switch to IIS Manager.
  2. In the Connections pane, select the server, site, or application you want to configure.
  3. Right-click the item. On the context menu, click Manage WCF and WF Services, and then click Configure.Alternatively, you can use the Actions pane instead of the context menu. Find the Manage WCF and WF Services section, and then click Configure.
  4. When the Configure WF and WCF dialog box appears, click the Monitoring tab.
  5. View or change settings as necessary. If you change settings, click OK to apply the settings and close the dialog box, or click Apply to apply settings without closing the dialog box. Click Cancel to close the dialog box without saving. (source MSDN

Note : the second modify the config file too

How To disable development server

People who have large solution with lot of differents projects type (BizTalk, c# WCF….) may want to disable the debugging webserver, when they enter in debug mode.

On the web you can find lot of solution like updating regiter key or delete web debug server.

But the simpliest technic is to disable the project to start the debug asp server :

Click on the project, then go to the property tab and set to false the property « Always Start When debugging » :

SQL-WCF port and OperationName

When you generate a binding with Add generated item ->consume WCF adapter and import it in BizTalk you could meet this issue when you try to test it :

The adapter failed to transmit message going to send port "WcfSendPort_SqlAdapterBinding_TypedProcedures_dbo_Custom" with URL "mssql://.//MeteorLogging?". It will be retransmitted after the retry interval specified for this Send Port. Details:"Microsoft.ServiceModel.Channels.Common.UnsupportedOperationException: The action "<BtsActionMapping xmlns:xsi="" xmlns:xsd="">
  <Operation Name="spBTS_WebUp_Meteor_EntLibLogging_WriteLog" Action="TypedProcedure/dbo/spBTS_WebUp_Meteor_EntLibLogging_WriteLog" />
</BtsActionMapping>" was not understood.

Lire la suite

WCF instanceContextMode

With WCF, you can configure lot of thing.

An interesting setting is the InstanceContextMode

MSDN talk about that :  « Use the InstanceContextMode property to specify when new service objects are created. Because the service object is not directly connected to the communicating channel, the lifetime of the service objects is independent of the lifetime of the channel between a client and the service application. The default value, PerSession, instructs the service application to create a new service object when a new communication session is established between a client and the service application. Subsequent calls in the same session are handled by the same object. » ( Lire la suite

WCF custom vs WCF with IIS

In a previous blog entry, I wrote about exposing wcf port without IIS. But now when I use IIS and when I don’t use it ?

Actually, when I use IIS I’ve got a new technic layer and increase the resource used.

So what IIS bring more.As we can see with or without IIS doesn’t influence response time (click on the picture to zoom). Lire la suite