TransactionException op WCF two-way send port

On a 2-way WCF send port, I was getting an error for some of the calls it was requesting to the webservice. It turned out that the exception only occured for very large response files that had to be responded from the webservice.

To get the response file correctly, I already had to increase the TimeOut settings on the send port for the binding of the WCF-Custom adapter. But still I got an error with following message:

Message: SP_Dummy_WCF – System.Transactions.TransactionException: The operation is not valid for the state of the transaction.

at System.Transactions.TransactionState.EnlistVolatile(InternalTransaction tx, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction)

at System.Transactions.Transaction.EnlistVolatile(IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions)

at Microsoft.BizTalk.Adapter.Wcf.Runtime.TxnBatch2..ctor(IBTTransportProxy transportProxy, ControlledTermination control, Transaction transaction, ManualResetEvent orderedEvent, Boolean makeSuccessCall)

at Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkDeleteTxn.Execute(BizTalkExecutionContext executionContext)

So to rule out any timeouts coming from the adapter itself, I configured all the WCF TimeOuts to 1 hour.

WCFTimeOutSettings

Unfortunately, this didn’t help out a thing.¬†So I kept looking for a correct solution.

Solution 1:

After some digging around, I found out the transaction max time out had to be increased. If this setting is not specified, it defaults to 10 minutes, and it cannot be overridden in code even. I ended up configuring this maximum transaction time out in the machine.config files of the server. Just add following in the machine.config file and restart all host instances to solve the issue:

<configuration>
<system.transactions>
<machineSettings maxTimeout=”00:59:00″ />
</system.transactions>
</configuration>

 
Note that this change will affect all transactions on this server.

Solution 2:

A second solution to this problem might be even more interesting, because the transaction setting will only be applied to this specific port. All credits go to Coen Dijkgraaf, check out his blog post here.

You can make sure that the port doesn’t use any transactions, by disabling it on the adapter configurations on the port.
Just open the port properties and click on the Configure button to change the WCF adapter settings. Open the Messages tab, and under Transactions you’ll see a checkbox to enable/disable transactions for this port.

Uncheck the checkbox to disable the use of transactions, and this would enough to solve the issue.

WCF-Transaction

Some info on this setting can be found at http://msdn.microsoft.com/en-us/library/bb226442.aspx.

Advertisements

Using Fiddler for viewing exchanged messages with BizTalk

I was trying to view the SOAP messages and headers that were actually exchanged with a certain webservice.
To do so, I used Fiddler2… available from http://fiddler2.com/.

Fiddler2 will allow you to monitor traffic when using HTTP, SOAP or WCF ports in BizTalk. However, Fiddler will not trace any messages sent to endpoints by BizTalk by default as it does not use WinInet. To overcome this issue, you’ll need to configure a proxy to allow Fiddler to intercept the messages.
Note that these proxy settings will need to be removed when Fiddler is not running. Because otherwise all traffic through this proxy will not be received by anything.

In the send port of BizTalk go to the Configuration settings. Open the tab ‘Proxy’ to configure the necessary settings. Now you should change following settings:

  • Server: 127.0.0.1
  • Port: 8888

ProxySettingsInBTS

That’s is all you need to do. Now open fiddler2 and process a message.
If all is configured correctly, you should see the exchanged messages coming through fiddler.
Fiddler

WCF-Oracle adapter for BizTalk 2009

This article will give a short and easy explanation on how to use the WCF-Oracle adapter to retrieve a result set from an Oracle database.

The first thing we need to have on the Oracle database is a stored procedure that returns an object of the type ref-cursor.
This article will give some examples on how to program them. The second thing we need to do is to install an oracle client.
This has to be done so we can add an oracle service that can connect to the database, this service will be used later on to retrieve the metadata.
Installing the client will also add the necessary oracle drivers. In this example we added the service Oracleblog with the right settings for our database.

Now we can start developing.
The first step of the development is to generate the metadata and the request-response schemas.
We start by creating a BizTalk project in Visual Studio. After having created the project, we right-click the project and choose “add generated item”. Now we choose “Consume Adapter Service” to start the wizard. This new wizard was added in Visual Studio by installing the WCF-Oracle adapter.

In the wizard we first choose OracleDBBinding for “Select a binding” then we click “configure” to configure the database settings. The first thing we do is adding the name of the service we created in the oracleclient in the field DataSourceName on the pane URI. After this we can add the required credentials. Now making the connection by clicking “connect” will show all the databases available. We have to find the right stored procedure and add this to your BizTalk project. In our example we added the stored procedure P_SEARCH.

Adding it to your project will give you two things:

The request-response schema
The binding file for your send port

In this example two schemas are generated, this is because one schema is referring to the other. Both request and response schemas are created in the same XSD-file. Now we can create a simple orchestration in which we make a mapping to the request schema and create a request-response port so we can send the request and receive the file with the record set.

Now we deploy the project to add the orchestration to the BizTalk server. The next thing we do is creating the proper send-receive port for sending to the oracle database. We do this by importing the binding file that was generated with the schemas in to our BizTalk application. This will create the send-receive port with the correct action- and database settings. We now make a file receive and send port and bind this to our orchestration.

We are now ready to send the message.