1

I would like to know if there's a way to configure BizTalk to have an orchestration that wouldn't constantly poll a folder for a file, but would rather check for a file "on-demand".

By "on-demand", I mean that I need BizTalk to "wait" for a web service call (via WCF port) and then go fetch a file in an FTP folder and start the orchestration.

Is it something feasible? I read that "Dynamic ports" could be used for that, is it true?

Thanks, Alex

2d1b
  • 595
  • 1
  • 6
  • 24

3 Answers3

3

You could dynamically create a FILE (or FTP) receive location in an orchestration that is activated by the WCF Receive Port.

Brian Loesgen blogged a simple example of code that could be called by your orchestration to create receive locations. If the server and folder names do not change from one call to the next, then you could use the same receive location each time and just activate/deactivate it at run-time.

Here is another Stack Overflow question that specifically addresses activating a receive location in code: Is there a way to automate turning a BizTalk Receive Location on or off through code? Create a new class project in Visual Studio, add in a reference to Microsoft.BizTalk.ExplorerOM, write a few lines of code, and you've got your helper assembly!

Here's a sample from MSDN to create and configure an HTTP receive location:

private void CreateAndConfigureReceiveLocation()
{
   BtsCatalogExplorer root = new BtsCatalogExplorer();
   try
   {
      root.ConnectionString = "Server=.;Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;";

      //First, create a new one way receive port.
      ReceivePort myreceivePort = root.AddNewReceivePort(false);

      //Note that if you dont set the name property for the receieve port, 
      //it will create a new receive location and add it to the receive       //port.
      myreceivePort.Name = "My Receive Port";

      //Create a new receive location and add it to the receive port
      ReceiveLocation myreceiveLocation = myreceivePort.AddNewReceiveLocation();

      foreach(ReceiveHandler handler in root.ReceiveHandlers)
      {
         if(handler.TransportType.Name == "HTTP")
         {
            myreceiveLocation.ReceiveHandler = handler;
            break;
         }
      }

      //Associate a transport protocol and URI with the receive location.
      foreach (ProtocolType protocol in root.ProtocolTypes)
      {
         if(protocol.Name == "HTTP")
         {
            myreceiveLocation.TransportType =  protocol;
            break;
         }
      }

      myreceiveLocation.Address = "/home";
      //Assign the first receive pipeline found to process the message.
      foreach(Pipeline pipeline in root.Pipelines)
      {
         if(pipeline.Type == PipelineType.Receive)
         {
            myreceiveLocation.ReceivePipeline = pipeline;
            break;
         }
      }

      //Enable the receive location.
      myreceiveLocation.Enable = true;
      myreceiveLocation.FragmentMessages = Fragmentation.Yes;//optional property
      myreceiveLocation.ServiceWindowEnabled = false; //optional property

      //Try to commit the changes made so far. If the commit fails, 
      //roll-back all changes.
      root.SaveChanges();
   }
   catch(Exception e)
   {
      root.DiscardChanges();
      throw e;
   }
}
Community
  • 1
  • 1
schellack
  • 10,144
  • 1
  • 29
  • 33
1

Unfortunately the only thing BizTalk provides for this is something called a service window which allows you to schedule receive locations to turn on and off.

However it's very restrictive, with a single window per 24 hour period only. Also you have to know the times upfront.

Dynamic ports only apply to the send of messages, not for receiving them.

tom redfern
  • 30,562
  • 14
  • 91
  • 126
0

If you control the web service in any way, then you can always loosely couple the two systems using a queue or a database table, i.e. change the web service so that when a call is made, a message for BizTalk is placed in a queue/table. Then hook up your orchestration to the same queue/table so that it fetches a file "on demand". This scenario may not be entirely appropriate in your situation, but that's probably the closest you can get...

Fabio
  • 730
  • 3
  • 10