System.ArgumentNullException: Value cannot be null. Parameter name: key

Many of the in-built BizTalk adapters used WCF, including connections to Microsoft SQL Server, Oracle databases, and web services. BizTalk is very strict about supplying a SOAP Action header, and if you forget to specify it in the send port, you will get this particularly unhelpful error:

System.ArgumentNullException: Value cannot be null.
Parameter name: key

This is easy enough to correct by opening the Send Port properties, hitting the Configure button against your transport, and editing the SOAP Action header field. But wait, what if you’ve no idea what to put in there?

Let’s rewind a little. When developing this integration, you probably (hopefully) generated the relevant schemas for the WCF service in Visual Studio. You probably did this by adding a Generated Item, and choosing the option to Consume Adapter Service.

Single Action ports

If your port is only carrying out a single action (the simplest scenario – e.g. inserting records into a single table), you can lift the SOAP Action header straight from the relevant generated schema. Just open the schema (it’s the one named after the relevant entity, e.g. the table name), and within there should be one node for each operation (e.g. “Insert”). Look for the relevant operation, and you will see a value for <doc:action> in the <xs:documentation> section. You can simply paste this into the SOAP Action header field. I’ve highlighted the relevant schema section in this screenshot.

Composite Operation

Some BizTalk adapters (e.g. WCF-SQL) are smart enough to allow a port to perform multiple operations in the same transaction, and thereby roll them all back if something goes wrong. For example, this could include inserts into multiple tables (maybe one table is for details of a Person, and another separate table holds their Address, and you want these inserts to succeed or fail together).

In these cases, your port will be using a combined schema containing multiple entity and operation schemas within. In this case, the SOAP Action header is actually simpler, because you should just populate the field with the special value CompositeOperation (just that exact text), and NOT the path to a specific action. The adapter then understands that the port will be carrying out a composite operation involving multiple actions.

Leave a comment

Your email address will not be published. Required fields are marked *