Tuesday, December 3, 2013

Custom File Adapter for Pooling Interval

The Pooling Interval property decide how long system should wait to poll the receive location again, if it get no message last time it polls.

Polling intervals in File/FTP adapters not works as expected, This is how it works
1. You drop 4 files at a time.
2. Biztalk File/FTP adapter reads 1 file at a time (according to batch size=1)
until the receive location is empty.
          This means while your first file being picked up, Biztalk FTP/File adapter identifies 3 more files are pending. So FTP/File adapter discards the polling interval and pick one after the other until your receive location is empty.

3.If the receive location is empty , it waits util the next polling interval.

I think the batching works well but it seem like it does not wait for the polling interval.

We want to change the behavior for the Pooling Interval property, it is all about performance. We don't want our CPU to be fully occupied with receiving messages because lots of them arrived is a short period of time, maybe making our system to work really slow, expiring timeout of other ports.

Microsoft released all the most important BizTalk parts with source code, we can locate those in C:\Program Files (x86)\Microsoft BizTalk Server 2010\SDK\Samples and in this directory exist the source code of the BizTalk file adapter, HTTP adapter, and we can find all the base class library here which will be useful to develop a new BizTalk Adapter.

we'll use the source code of the File Adapter (located in AdaptersDevelopment\File Adapter)



In the directory we'll find ,BizTalk Project directory with one BTS sample, Design Time directory is a project to manage adapter configuration, Runtime directory is the project of adapter runtime.

     Runtime project is the most important, open it, in this project you can observe the two principal files DotNetFileReceiverEndpoint.cs that contain the code for receive the stream and DotNetFileTransmitterEndpoint.cs that contain the code to transmit the stream.
In DotNetFileReceiverEndpoint.cs

  • public void ControlledEndpointTask (object val)


        {
            if (this.controlledTermination.Enter())
            {
                try
                {
                    lock (this)
                    {
                        this.EndpointTask();                      
                    }
                    GC.Collect();                  
                }
                finally
                {
                    this.controlledTermination.Leave();
                    Thread.Sleep(new TimeSpan(0, 0, 0, ((int)this.properties.PollingInterval)));
                }
            }
        }

  •     In PickupFilesAndSubmit(), modify the existing code with the below one.

         FileInfo[] items = di.GetFiles(this.properties.FileMask)
               Add System.Linq; namespace at the using block.
        FileInfo[] items = di.GetFiles(this.properties.FileMask).Take(maxNumberOfFiles).ToArray();
     


  • please add the below code, to avoid The process cannot access the file because it is being used by another process error. 

               // If we couldn't lock the file, just move onto the next file
                IBaseMessage msg = CreateMessage(fileName, renamedFileName);
                             
                MemoryStream ms = new MemoryStream();
                msg.BodyPart.Data.CopyTo(ms);
                msg.BodyPart.Data.Position = 0;

                if ( null == msg )
                    continue;

                if ( null == renamedFileName )
                    files.Add(new BatchMessage(msg, fileName, BatchOperationType.Submit));
                else
                    files.Add(new BatchMessage(msg, renamedFileName, BatchOperationType.Submit));
             
                if (ms.CanSeek)
                {
                    ms.Position = 0;
                }
                msg.BodyPart.Data = ms;

                //  keep a running total for the current batch
                bytesInBatch += item.Length;

Now we can rebuild our adapter and have to register it.

To register the adapter we must execute the registry file StaticAdapterManagement.reg, we found some possible issues in this file.

The first is the directories, check all path directory because all are wrong:

  • C:\Program Files\Microsoft BizTalk Server 2010\SDK\Samples\AdaptersDevelopment\FileAdapter\Runtime\bin\Debug\Microsoft.BizTalk.SDKSamples.Adapters.DotNetFile.Runtime.dll”


  • “OutboundEngineCLSID”=”{024DB758-AAF9


  • Is not FileAdapter but File Adapter
The second, check if your sample is under Program Files or Program Files (x86) in case modify the path or create your own different directory project.

The third and the most important is, if your BizTalk run in 64 bit mode you must modify the registry keys because BizTalk server in 64 bit search configuration under Wow6432Node



So, for example, if you want work with BizTalk configuration in 32 bit mode the correct string is
[HKEY_CLASSES_ROOTCLSID{62018D08-281A-415b-A6D3-6172E3762867}]
in 64 bit is
[HKEY_CLASSES_ROOTWow6432NodeCLSID{62018D08-281A-415b-A6D3-6172E3762867}]

In the BizTalk Admin console, right click on the adapters, new and select Static DotNetFile, for the adapter name as you want.



Restart the host instance
Create one receive port, one send with correct filter and test the solution





The result must be this

Here we have set the Number of files in Batch as 2 and Pooling interval as 60 seconds.

Thursday, November 14, 2013

Failed to start the BizTalk Host instance. Check the event log on the server for more details.

Have you done any changes to BizTalk config file recently. Can you open the file in any XML editor any check it has any format error. Also check for a custom entires, which may not be vaild. I would have taken backup of the config files before any chances, if you have then compare the changes. If you have done some changes make sure you have done them in the 64bit config files.

Thursday, November 7, 2013

System.Xml.XmlDocument is not marked as serializable in BizTalk

XmlDocument is not a serializable type.

     This error usually occurs when an orchestration (which uses any of your assembly that has XmlDocument type field) is going to be dehydrated, the BizTalk engine is going to serialize every variable.

     This won't apply to variables that are of the XmlDocument type in the orchestration as BizTalk knows it's not serializable and won't try. Because this is so widely used that it is treated as a special case. The BizTalk Engine knows how to serialize it so the XLang compiler doesn't raise an error. The serialization process saves the type of the variable and the value of the OuterXml property, which can then later be used to instantiate a matching
System.Xml.XmlDocument when deserializing.


I got this exception when we want to receive a response type as System.Xml.XmlDocument from a C# class. or if we have System.Xml.XmlDocument object declaration at class level.

 Use Default Constructor property causes an instance of the object to be constructed when the orchestration instantiates. If this property is set to False, the variable will need to be instantiated in an Expression shape through the new keyword. Try this, otherwise use below option.
                                      OR

Mark the member as NonSerializable. BizTalk will not attempt to serialize the object and you shouldn't see this error
                                     OR
The solution is very simple: if you're using, in any of your orchestrations, assemblies that have a XmlDocument type field as a response. Then make that class and members are static (No instance, no persistence, no serialization).


Possible error is:
Type 'System.Xml.XmlDocument' in Assembly 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.

   




Tuesday, September 24, 2013

Compensation block


Scope: Scopes are used for three reasons:

  1. to configure transaction (long running or atomic)
  2. to handle exceptions
  3. to trigger compensating logic


A scope shape can have one or more Exception handling blocks and one Compensation Block. The Transaction type you've chosen for your scope will define which of these blocks can be added. An atomic scope can only have a compensation block, and a scope configured with the transaction type none can only have an Exception block. While a long running scope can have both blocks.

For an overview of the possibilities, check the below screenshot.



There could be more than one Exception block, but only one Compensation block added to a Scope.


Compensation block
Compensation is a way to correct or undo logical piece of work that have previously committed. 
       An exception can occur in the orchestration after successfully executing all logic in the scope. In this case, the process might be in a state where it is logically incorrect. So the action already performed in a transnational scope need to be compensated... this can be achieved using a compensation block
If no compensation block is added, the default compensation will be performed. this means calling all compensation blocks of the nested scopes, starting with the most recently completed ones, just as with the default exception handler.

Compensations blocks may be created for both atomic and long running transactions.  Compensation blocks must be explicitly invoked. To invoke the Compensations block, finally drop the "Compensate" shape into the exception handler block (Compensate shape can be placed only in exception or compensation block) and set the "Compensation" property to the corresponding transaction name in the properties window.

A particular scope can be compensated only once.The compiler will prevent more than one path leading to the compensation of a particular scope.

Compensate
      The compensate shape can only be used inside of an exception handler. The explicit use of this compensate shape, allows us to specify the order of compensation execution ourselfs. So this can be used in cases the default order (starting from te most recently completed ones and working its way back) doesn't fit.
1 compensate shape can only trigger 1 compensation block of a transaction. So the order must be defined using multiple compensate shapes, calling the compensation blocks in the desired order.




When an Atomic transaction throws an exception, this will generally be caught at an outer non-atomic scope. Atomic scopes cannot have exception handlers of their own. Compensation can only be invoked if the exception is caught by an outer LongRunning transaction.

For Ex:
Image
Consider the above scenario for basic compensation model

We have 1 LongRunning transaction and 3 nested atomic transactions which insert data in DB with their compensation blocks associated with them,now the 3rd atomic transaction fails to commit then it invoke the compensation block in backward direction .

Execution order:

Insert into Table1(scope Shape)
Insert into Table2(scope Shape)
Insert into Table3(scope Shape) —  not commited
Catch exception
Compensation block 2
Compensation block 1

Thursday, September 19, 2013

What are the different types of transactions available for orchestration?

A scope with no transaction is usually used as a try/catch block just to handle exceptions.

BizTalk Server supports two distinct types of transactions: atomic and long-running.

     Transactions are implemented in Orchestrations using Atomic Scope. An Atomic Scope supports ACID properties of Transactions where as Long Running Scope Supports C&D (Consistency and Durability) properties of ACID.



AtomicAn atomic scope cant be placed within a Normal Scope.
There are two other Advantages of Atomic scope in addition to supporting Transactions.

1. Non-Serializable classes can be called from an Atomic Scope.

2. The number of Persistence points within an Orchestration can be reduced as an atomic scope will always induce one Persistence point (at the end of the scope).

Long running:  A business process that might take seconds, minutes, or even days or weeks to complete. This is when a long-running transaction is more suitable.

Wednesday, September 11, 2013

Enlist Vs UnEnlist (State information about BizTalk Server artifacts)

BizTalk Server has many artifacts such as send ports, send port groups, receive locations, parties, and orchestrations. Of the artifacts, send ports, send port groups, and orchestrations  have a state, which determines whether the artifact can process messages.

We have four variants with messages received by adapter :

1).  After Subscriber is Enlisted and Started, the messages come to the Message box and then routed to the Subscriber.
2). After Subscriber is Enlisted but not Started yet, the messages are waiting inside Message box in the Suspended (Resumable) state. When Subscriber is started, those messages go out from Message box to this Subscriber.
3). If the Subscriber is not Enlisted, and the message type in well-known by BizTalk, we'll get error
Description:
The Messaging engine failed to process a message submitted by adapter:{adapter details}. Details:Could not find a matching subscription for the message. This error occurs if the subscribed orchestration schedule or send port has not been started, or if some of the message properties necessary for subscription evaluation have not been promoted. Please refer to Health and Activity Tracking tool for more detailed information on this failure
It means the message was recognized by BizTalk, because BizTalk knows of its type. But there is no one subscription to this message.

UnEnlist:- Remove subscription information from Message Box.
Stop:-Will not Remove Subscription information form message box but the port or orchestration will not process(send) messages.
Enlist:-Write Subscription information into message Box(Bound).
Start:-Process(send) messages.

Don't confuse with Stop and Enlist
the "Stop" changes the state from "Started" to "Stopped/Enlisted". 
the Enlist will move from Unenlisted to "Stopped/Enlisted" state.

Ex:
you have a mailbox at the local post office.  When you go out of town on vacation, you drop from the "Started" to the "Enlisted" state.  They hold your mail for you, and when you return, they give you the box full of mail.  When you move out of town (or are tired of all the junk mail), you "Stop" your mail and they post master marks it as undeliverable.

Friday, September 6, 2013

InternalServiceFault - The value of a promoted property cannot exceed 256 characters. Property "Action" Namespace "http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties".


I tried to invoke a WCF service from within an orchestration and got the below fault message in response


<Fault xmlns="http://www.w3.org/2003/05/soap-envelope"><Code><Value>Receiver</Value><Subcode><Value xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</Value></Subcode></Code><Reason><Text xml:lang="en-US">The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the &lt;serviceDebug&gt; configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.</Text></Reason></Fault>

after IncludeExceptionDetailInFaults = ture got below exception.

<Fault xmlns="http://www.w3.org/2003/05/soap-envelope"><Code><Value>Receiver</Value><Subcode><Value xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</Value></Subcode></Code><Reason><Text xml:lang="en-US">The value of a promoted property cannot exceed 256 characters. Property "Action" Namespace "http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties".
Parameter name: obj</Text></Reason><Detail><ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><HelpLink i:nil="true" /><InnerException i:nil="true" /><Message>The value of a promoted property cannot exceed 256 characters. Property "Action" Namespace "http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties".
Parameter name: obj</Message><StackTrace>   at Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkServiceInstance.EndOperation(IAsyncResult result)
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkServiceInstance.Microsoft.BizTalk.Adapter.Wcf.Runtime.ITwoWayAsync.EndTwoWayMethod(IAsyncResult result)
   at AsyncInvokeEndEndTwoWayMethod(Object , Object[] , IAsyncResult )
   at System.ServiceModel.Dispatcher.AsyncMethodInvoker.InvokeEnd(Object instance, Object[]&amp; outputs, IAsyncResult result)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeEnd(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage7(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage6(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace><Type>System.ArgumentOutOfRangeException</Type></ExceptionDetail></Detail></Fault>


The problem was solved.
In my case WCF service (logical)port operation name from orchestration was not equal with operation name in physical port binding properties.

or 

Go to send port -> Configure and SOAP Action Header section.
Remove below lines

<BtsActionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Operation Name="OperationXXXName1" Action="OperationXXXName1" />
  <Operation Name="OperationXXXName2" Action="OperationXXXName2" />
</BtsActionMapping>

And keep only one action in the SOAP Action Header section. (i.e OperationXXXName1).


Thursday, September 5, 2013

WCF-BasicHttp - ActionNotSupported


Last 4 hours I was hanging with the below error while testing my BizTalk Orchestration to send an request message to External wcf Service.

<s:Fault xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode><faultstring xml:lang="en-US">The message with Action '{service url}' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</faultstring></s:Fault>



Fix is very simple, we have to update the Action value in configure->general-> Action section

In order to integrate external WCFServices in BizTalk, both Schemas have to match.
If the External WCFService schema does not match the BizTalk schema, BizTalk will not be able to send the request. 

WCF adapter tries to match the operation name with an action defined in the BtsActionMapping, and if it can't find the Operation context property in the BTS message, it'll throw exception.


Another thing you can look at is the ENDPOINT properties... and make sure all parameters are properly set.

A good test is to use a Soap Tool to test your External WebService. You can try SoapUI tool
add your service to the SOAPUI and verify the operation action actions in the below shown screen.



if the BtsActionMapping is different, please update latest in the properties and verify. it'll fix the issue.
 

Tuesday, July 2, 2013

Understanding Design-Time Properties for Custom Pipeline Components in BizTalk Server

Default Pipelines

When you create a new application, the default pipelines are created and deployed by default and appear in the Microsoft.BizTalk.DefaultPipelines assembly in the \References folder for every BizTalk project. The default pipelines cannot be modified in Pipeline Designer. These pipelines can be selected when configuring a send port or receive location in BizTalk Explorer.

Note:  The XML receive and XML send pipelines do not support XML documents larger than 4 gigabytes.

BizTalk provides 2 Receive pipelines (PassThruReceive, XmlReceive) and 2 Send Pipelines (PassThruSend, XmlSend), we can go and build more custom pipelines if required.


The default PassThruReceive and PassThruSend pipelines doesn't do any processing at all with the message and it will n't have any components. Whereas the XmlReceive pipeline will have a XmlDisassembler pipeline component on the disassembling stage and the XmlSend pipeline will have a XmlAssembler on the Assemble stage as shown in the above figure.

Why do we need a XmlReceive pipeline:
Whenever an Xml message is received via the XmlReceive pipeline the XmlDisassembler will do the following tasks:
1.Promote the "MessageType" context property by taking the combination of TargetNamespace and Rootelement in the format, Targetnamespace#RootElement.
2. Remove Envelopes and disassemble the interchanges
3. Promote the content properties from interchange and individual document into message context based on the configured distinguished fields and promoted properties.

There are 3 important things you need to keep in mind.
1. Maps on the receive side will be applied after the receive pipeline. In order to pick the correct schemas for processing, Maps need the "MessageType" property, which is promoted by the XmlDisassembler. So, if you are using PassThruReceive "MessageType" property won't be present, which in turn will result in Map not being applied.

2. Binding of logical port in the orchestration to a message (inside the orchestration designer), and deploying the orchestration will create the subscription for the particular message type. So, if you are using PassThruReceive "MessageType" property won't be present, which in turn will result in not starting the particular Orchestration instance.

3. If you have configured content based routing based on the properties in the message (Filters in SendPorts, Example: BTS.MessageType = http://tempuri#Person), routing won't happen until the correct properties are present in the message context.


Why do we need a XmlSend pipeline?
XmlSend pipeline does the reverse of what a XmlReceive pipeline did. It got a XmlAssembler component in the Assemble stage  which does the following tasks:
1. XML Assembler Builds envelopes as needed and appends XML messages within the envelope.
2. Populates content properties on the message instance and envelopes.

ref: http://www.digitaldeposit.net/saravana/post/2007/01/31/Difference-between-(PassThruReceive-PassThruSend)-and-(XmlReceive-XmlSend)-Biztalk-Pipelines-(For-Beginners).aspx

Wednesday, June 5, 2013

String Variables in Orchestration: Use Quotation Marks when Assigning Initial Value

When working with Orchestrations in BizTalk, if you create a variable that’s a string type and assign its initial value, you’ll want to make sure that you put quotation marks around the value.  I failed to do so recently I had errors similar to these pop up when attempting to build the project:

identifier 'YOUR_VARIABLE_VALUE' does not exist in 'YOUR_ORCHESTRATION';  are you missing an assembly reference?

Saturday, May 25, 2013

How to test Map if it has multiple source messages


A nice feature of BizTalk is the possibility to have many-to-one maps. This means that a single map requires multiple input messages and produces a single output message. This type of mapping is often required to support complex message flows.
When you create a map, you see a wizard-like screen in which you have to specify input and outputs message types, as well as the map name. Based on that, BizTalk generates an empty map for you. In case you have specified multiple input message types, BizTalk will generate a single message schema internally. This schema contains references to all input message types.
Testing a many-to-one map might be difficult. The “test map” option of the map allows for only a single input message to be specified. Instead of passing multiple test messages to the test option, you should pass a single message of the (internally used) message definition that was generated based on the individual message types.
This is how you can get hold of the XSD of this generated message definition:
  • Locate the file that contains the many-to-one map, and open it with a text editor.
  • Find the SrcTree tags. Copy all text that is in between the opening and closing tag named SrcTree.
  • Paste the text in a new text document.
  • In the document, you will see tags with names like InputMessagePart_0, InputMessagePart_1, InputMessagePart_2. Those contain the references to individual message types
  • Remember which definition is referenced to under each InputMessagePart_n-section. Then delete the contents of each InputMessagePart_n-section
  • Save the document as a text file, and change the extension to xsd. Take care that the xsd and the many-to-one map are in the same folder
  • Go to VisualStudio, and open your project. Add the new xsd to the project (add existing item), and open it.
  • Go to the Schema-node, properties, imports. Remove the references to the individual message types. Note: do not remove the other imports.
  • Save and close.
  • Using the context menu for this xsd, generate an message instance, and check where it is stored.
  • You have just created an “empty shell“ XML-message. Open this message with a text or XML-editor. Paste your original test messages (for each message type being input to the map) in the proper InputMessagePart_n-section. Do not copy xml-headers, just the plain message
  • Save the file.
This is it: you have created a test message to be used with your many-to-one map as test input. Link the instance to the map, then test it.
If you think that this is a lot of work for simple testing, bear in mind that the alternative is to go through this cycle for each and every small change you need to make to the map:
  • Unenlist the orchestration
  • Undeploy the projects
  • Rebuild the project
  • Deploy the projects
  • Bind the orchestrations
  • Start the orchestrations
  • Go thorugh a test sequence.

Wednesday, May 22, 2013

BizTalk Deploy Error: Could not enlist orchestration ‘MyAssembley’. Object reference not set to an instance of an object. (Microsoft.BizTalk.SnapIn.Framework)

Today after I deploy and configure a new version of an existence solution, I tried to start the application and it gave me the following error:


Could not enlist orchestration '<MyAssembly>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bcfb9271ae6d2402'. Could not enlist orchestration

NullReferenceException exception occurred while the XLANG/s runtime enlisted a service.
Error message:Object reference not set to an instance of an object.
Call stack:   at Microsoft.BizTalk.XLANGs.BTXEngine.OrchestrationMetadata..ctor(String assemblyName, String orchTypeName, Delegate satAssemblyCacheCallback)
   at Microsoft.BizTalk.XLANGs.BTXEngine.BTXServiceStaticState.PersistState(String mgmtDBServer, String mgmtDBName, String MsgBoxGroupName, String ApplicationName, String serviceAssembly, String serviceTypeName, Guid[] PortIDs, Guid[] LrpIDs, Delegate satAssemblyCacheCallback, ITransaction transaction)
   at Microsoft.BizTalk.XLANGs.BTXEngine.EnlistAppDomainHelper..ctor(String configDBServer, String configDBName, String msgBoxGroupName, String applicationName, String servicePath, String serviceTypeName, Guid[] portIDs, Guid[] lrpIDs, Delegate satAssemblyCacheCallback, ITransaction transaction)
       
Object reference not set to an instance of an object. (Microsoft.BizTalk.SnapIn.Framework)



CAUSE
This maybe happens because the DLL’s presents in the GAC are not correct, or they are missing.

SOLUTION
Remove all the DLL’s and then deploy afterward or update them in GAC, normally solves this problem.

SOLUTION 2
Remove all the DLL’s and then change the DLL version (for example 1.0.0.1) and deploy the solution also, normally, solves this problem

But because today I was a little lazy and my lab machine had several windows updates to do, I decided to make a restart to my environment and install all updates and then deal with this error  .

Then came the best part, I decided to make one more shot, without changing anything, just application start J and IT WORKS!!

SOLUTION 3
Restart your machine!

refer: http://sandroaspbiztalkblog.wordpress.com/2011/05/11/biztalk-deploy-error-could-not-enlist-orchestration-myassembley-object-reference-not-set-to-an-instance-of-an-object-microsoft-biztalk-snapin-framework/


Monday, May 20, 2013

BizTalk Scheduled Task Adapter

The BizTalk Scheduled Task Adapter is an in-process receive adapter that executes a prescribed task on a daily, weekly or monthly schedule. The adapter is configured entirely within BizTalk, all configurations is stored within the SSODB and can be exported and imported via binding files.

The schedule capabilities are similar to those available with the Windows Scheduled Task Service.

Four simple tasks are included:
* XmlStringStreamProvider - generates a BizTalk message from a configured Xml string
* FileStreamProvider - generates a BizTalk message from the contents of a file
* HttpDownload - generates a BizTalk message from data downloaded from a web site
* SQLStreamProvider - generates a BizTalk message from the contents of a SQL Query (similar to the old SQL adapter) - Since version 3.0

Ref: http://biztalkscheduledtask.codeplex.com/releases

Saturday, May 18, 2013

Error: "The published message could not be routed because no subscribers were found."


I am getting the error "The published message could not be routed because no subscribers were found." as shown below. Do you have any idea how I can get rid of it?



 As this error is stating that  "the subscribing orchestration or send port has not been enlisted, or if some of the message properties necessary for subscription evaluation have not been promoted." Let  trouble shoot this error by using the BizTalk Administration console. 

First check the properties in the context of message and verify if you can see the desired properties promoted.


hmmm ok I am opening the routing failure reports:

 
I can see the property 'Customer' is promoted in the context of message.

 
 Then the second step would be to check the subscription. Let me check the Activation Subscription:


I can't see any subscription. Have you forgot to enlist the Send Port/Orchestration.


check... forget to start the send port.

Then start it and resume the message again.
 I have started it and resuming the message.


still getting the same error

check the Activation Subscription details.


I can see that you have specified the wrong name in send port subscription. It is showing as "ab" and based on the value of property Customer in the context of the message I think it should be "abc". Correct it in send port filter and resume the message.


Ah!! at last it worked !!!

Tuesday, May 14, 2013

BizTalk–Looping through repeating message nodes in orchestrations


Say that you have an incoming BizTalk message with many repeating nodes, and you want to process each one the same. The easiest thing to do would be to use the envelope to split the single message into multiple messages, then have multiple instances of your orchestration handle each one (similar to how the HIPAA “multiple” message schemas work). But what if you need to do some work after every individual message has been processed? I’ll show you how to use the Loop functoid along with xpath queries to loop through the message.
In my case, I’m receiving a flat file where each line is a response to a transaction we have submitted. After mapping the flat file to xml, I get something like this:
<Response>
   <Record>
      <RecordId>xxx</RecordId>
      <SubmitterId>xxx</SubmitterId>
      <Status>xxx</Status>
   </Record>
   <Record>
      <RecordId>xxx</RecordId>
      <SubmitterId>xxx</SubmitterId>
      <Status>xxx</Status>
   </Record>
</Response>
I want to insert each Record into the database, then do some work once they’ve all been inserted.
The first step is to create the single Record version of the message. It’ll be basically the same as the incoming Response message, just without the Response node at the top:
<Record>
   <RecordId>xxx</RecordId>
   <SubmitterId>xxx</SubmitterId>
   <Status>xxx</Status>
</Record>
The schema needs to be created without a Target Namespace; you’ll see why later.
Next, create the orchestration, two messages:
  • FullResponse (using the full flat file schema)
  • SingleResponse (using the new single Record schema)
…and three variables:
  • counter - int
  • counterString – string
  • responseCount - int
Drag various shapes onto your orchestration until you wind up with something that look like this:
LoopingPost
I’ll start at the top and detail how each shape should be configured.
Receive – receives FullResponse message
Expression - here you’re going to use an xpath query to count how many Record nodes are in the FullResponse message:
responseCount = xpath(InstaMedResponse, "count(/*[local-name()='Response' and namespace-uri()='http://MyProject.Response_FF']/*[local-name()='Record' and namespace-uri()=''])");
counter = 1;
counterString = "1";
(Pay attention to the namespace, yours may be different)
Loop -  what’s the loop condition?
counter <= responseCount
Message Assignment – here we’re grabbing a single Record node and assigning it to the SingleResponse message:
SingleResponse = xpath(InstaMedResponse, "/*[local-name()='Response' and namespace-uri()='http://AnciPay.InstaMedResponse_FF']/*[local-name()='Record' and namespace-uri()=''][" + counterString + "]");
Remember how I said the new schema needs to be created without a target namespace? Your xpath query will return the Record node without a namespace. Also, we have to (unfortunately) use counterString rather than just counter.ToString(), otherwise BizTalk will complain about an xpath error.
Map – this one is optional for the demo; in my case I’m mapping it to the Request Side of a generated schema.
Expression – here we need to increment the counter:
counter = counter + 1;
counterString = counter.ToString();
Send & Receive -  I’m using a WCF port to save to a database (click here for a simple tutorial), but you could omit these steps if you want.
Expression – this can really be anything that you want to happen after every individual Record node has been processed – run a stored procedure, send email, whatever.
Compile, deploy and test. If you just drop the SingleResponse message to a send port (instead of the database), you should see your incoming message split into multiple messages.

Monday, May 6, 2013

BizTalk WCF OracleDB Adapter - 'invalid username/password' error

SqlPlus converts the username/password to upper case by default, while in the adapter, we don't convert them to upper case. Can you try specifying the username and/or password in upper case in the adapter and see if that works.

Wednesday, April 24, 2013

Calling a WCF-WSHttp service from SOAPUI


SOAPUI is a great free tool that helps you to frame up request messages generated based on a service’s metadata and use them to call on HTTP based SOAP services as well amongst other advanced features.
One of the most common questions I have been approached for recently is how to use SOAPUI to call on a WCF service with a WCF-WSHttp binding.  If you create a SOAPUI project based on your service’s WSDL and try running one of the requests without changing any of the advanced options then you will get an error message like the following – “The message with To ” cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher.  Check that the sender and receiver’s EndpointAddresses agree.”  You would not face this problem with a default WCF-BasicHttp binding.
The reason for this is that the WCF-WSHttp binding makes use of WS-Addressing which is an advanced feature that allows for messages to be easily routed through firewalls and other intermediaries.  In order to support WS-Addressing you need to set a few advanced properties in SOAPUI which aren’t enabled by default when you generate your project from a WSDL.
The first thing you need to do is focus on your request message and click on the WS-A (at least that is what it is called in SOAPUI 3.6) tab as highlighted in the below screenshot.
You now need to ensure that you’ve checked the tickbox against Enable/Disable WS-A addressing, set the Must understand dropdown box value to True, and ticked the Add default wsa:To tickbox as highlighted in the below screenshot.
If you call on the service now that should work (assuming you don’t have any security turned on for the service, you might need to apply more advanced settings to enable this).
Do also note that if you choose to use Message based security and you enable the Establish Security Context tickbox (the below screenshot is from a BizTalk WCF-WSHttp send port) then you will always get a failure from SOAPUI like the following – “The message could not be processed. This is most likely because the action xxx is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint’s binding.”  This happens because SOAPUI doesn’t appear to support this setting, you will need to turn it off while you are testing from SOAPUI or use an alternative testing tool.

Monday, February 18, 2013

Is there a difference between “throw” and “throw ex”?


Throw: It propagates the full stack information to the caller,
                      When you use the throw with an empty parameter, you are re-throwing the last exception. Or rethrows the original exception and preserves its original stack trace.
Sample:


static void Main(string[] args)
{
  try
  {
     Method2();
  }
  catch (Exception ex)
  {
     Console.WriteLine(ex.StracTrace.ToString());
     Console.ReadLine();
  }
}

static void Method2()
{
  try
  {
     Method1();
  }
  catch (Exception ex)
  {
     throw;
  }
}

static void Method1()
{
  try
  {
     throw new Exception ("This is thrown from Method1");
  }
  catch (Exception ex)
  {
     throw;
  }
}

Throw ex:

Sample:


static void Main(string[] args)
{
  try
  {
     Method2();
  }
  catch (Exception ex)
  {
     Console.WriteLine(ex.StracTrace.ToString());
     Console.ReadLine();
  }
}

static void Method2()
{
  try
  {
     Method1();
  }
  catch (Exception ex)
  {
     throw ex;
  }
}

static void Method1()
{
  try
  {
     throw new Exception ("This is thrown from Method1");
  }
  catch (Exception ex)
  {
     throw;
  }
}




Summary:


Reference link : http://dotnetinterviewquestion.wordpress.com/2012/06/06/c-training-difference-between-throw-and-throw-ex/