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.