locked
Reading the context properties RRS feed

  • Question

  • Hi All,

    I want to promote the bts.Application name and messageid , SP name in Biztalk and need to assaign the target schema.

    I am WCF adapter.

    Thanks.

    Thursday, May 26, 2016 7:25 AM

Answers

  • Hi,

    Application name refer: http://biztek.blogspot.in/2007/01/read-your-application-name-in-pipeline.html

    SPName refer: http://esgraham.blogspot.in/

    Note as mentioned previously, BTS.SPName is promoted by the Messaging Engine when publishing a response message from a Solicit-Response send port.

    You can read it like below:

    string strSPName= pInMsg.Context.Read("SPName",
    "http://schemas.microsoft.com/BizTalk/2003/system-properties");

    There are a number of ‘built in’ promoted properties that provide important information.

    All are mentioned here: https://blogs.msdn.microsoft.com/skaufman/2004/10/24/how-to-get-the-source-file-name-in-a-pipeline-component/


    Rachit Sikroria (Microsoft Azure MVP)

    Thursday, May 26, 2016 4:17 PM
    Moderator
  • So we have created the table with columns application name, messageid,formatedxml,SPname So we have to populate all the values to the table.

    Did the client specifically ask for these?  Why create problems for yourself?

    Also realize, you do not need the Application Name since you can derive that from the Send Port Name.  As Send Port can be in one Application only.

    Again, you have to realize the non of these need to be Promoted.  It won't make any difference.

    And keep in mind, all of this is automatically available in Tracking so you're basically doing a lot of work to recreate something that is already exists.  I absolutely guarantee you will create more problems than are solved by doing this.  I've seen it too many times.

    • Marked as answer by BizTalk1234 Monday, May 30, 2016 4:49 PM
    Thursday, May 26, 2016 5:19 PM
    Moderator

All replies

  • Hi BizTalk1234,

    I am not sure about the BTS.ApplicationName but for rest you can achieve this by accessing the Context Property in Orchestration( or with some helper class) read it and assign to the Destination schema Message.

    context.Read("BTS.SPName").... something like this.

    Hope this Helps!!!

    Please mark as Answer if you satisfy with reply.

    • Proposed as answer by vikas.a.mehta Thursday, May 26, 2016 11:44 AM
    Thursday, May 26, 2016 11:44 AM
  • Hi,

    For Application Name: you get the application name in orchestartion you have use the code given here.

    For SPName and messageid : Can you please explain bit more about your requirement for messageid and SP name. You can use BTS.SPName to get the SendPort name.

    If you can give us more information about your requirement, we can give you exact solution.


    Thanks, Girish R. Patil.

    Thursday, May 26, 2016 11:56 AM
  • Hold on, please explain exactly why you want to Promote these Properties.  MessageId is always different so you can really use it for anything as a Promoted Property.

    If you want to just access them, then just do it, they do not need to be Promoted.

    But, be aware that there is no such Property as BTS.Application so you'll have to use something different.

    As for assigning the values, the easiest way is by Distinguished Fields in the target Message like:

    MyMessage.MyRoot.MyElement.MyDistinguishedField = IncomingMessage(BTS.SPName);

    If you're doing this for 'logging', don't.  You should be using Tracking for that.

    Thursday, May 26, 2016 12:02 PM
    Moderator
  • Not clear with your requirement though.You can access the application name using BTSCatalogExplorer and Microsoft.BizTalk.ExplorerOM.ReceivePort classes.


    private string GetApplicationName(string ReceivePortName)
    {
    string retValue = string.Empty;
    BtsCatalogExplorer bc = new BtsCatalogExplorer();
    bc.ConnectionString = "Server=MyBTServer;Initial Catalog=BiztalkMgmtDb;INtegrated Security=SSPI;";
    
    foreach (Microsoft.BizTalk.ExplorerOM.ReceivePort rcp in bc.ReceivePorts)
    {
    if (ReceivePortName == rcp.Name)
    {
    retValue=rcp.Application.Name;
    }
    }
    return retValue;
    }


    The above shown method can be simply used in Receive pipeline and promote your application name in the message context, so that you can access it in your Orchestration.

    Create a new property schema with “ApplicationName” and write code similar to this.

    if (!pInMsg.Context.IsPromoted("ApplicationName", "http://...."))
    {
    string recPortName= pInMsg.Context.Read("ReceivePortName",
    "http://schemas.microsoft.com/BizTalk/2003/system-properties");
    pInMsg.Context.Promote("ApplicationName", "http://...",
    GetApplicationName(recPortName));
    }

    Refer: http://biztek.blogspot.in/2007/01/read-your-application-name-in-pipeline.html

    2) BTS.SPName is promoted by the Messaging Engine when publishing a response message from a Solicit-Response send port. you can always read it in the orchestration. 
    strSPName = Message(BTS.SPName);

    3) BTS.MessageID

    strMessageID = Message(BTS.MessageID);



    Rachit Sikroria (Microsoft Azure MVP)


    Thursday, May 26, 2016 12:04 PM
    Moderator
  • Hello,

    You can get the Application Name, Message ID and SP Name in orchestration only, then you can assign to your target schema from Message Assignment shape.

    The following is the code you can use...

    btsOps = new Microsoft.BizTalk.Operations.BizTalkOperations("Management DB Server ", "Management DB Name");
    msgBoxService = btsOps.GetServiceInstance(Microsoft.XLANGs.Core.Service.RootService.InstanceId);
    ApplicationName = msgBoxService.Application;   
    
    SPName = InboundSch(BTS.SPName);
    MessageID = InboundSch(BTS.MessageID);

    Here You have to add reference to class Microsoft.Biztalk.Operations.dll

    btsOps is a .net object for class Microsoft.BizTalk.Operations.BizTalkOperations,

    msgBoxService is a .net object for class Microsoft.BizTalk.Operations.MessageBoxServiceInstance.

    and InboundSch is the input Message.

    also you have to replace "Management DB Server" and "Management DB Name" by your MgmtDBServerName and MgmtDBName.

    Thanks,

    Sarva.


    • Edited by SarvaSetty Thursday, May 26, 2016 12:41 PM
    Thursday, May 26, 2016 12:38 PM
  • Hi BizTalk1234,

    You have to promote all the required fields in Receive pipeline and Use Context Accessors functoids to assign the destination schema.

    Please mark it as answer if it answer your question

    Thursday, May 26, 2016 1:34 PM
  • Hi All,

    We have some integration where we are pushing data to oracle and we are getting the response (WCF-Custom)  and storing it in some physical location. and we are not doing anything with that response.

    Client asked us to put that response into SQL table instead of folders. So we need to create the common application where we have put the response into SQL table.

    So we have created the table with columns application name, messageid,formatedxml,SPname So we have to populate all the values to the table.

    We are prefering the message based solution,So please advise how to promote the appname and SPname and Message Id and I also need to write to table columns the promoted properties.

    Thanks.

    Thursday, May 26, 2016 3:48 PM
  • Hi Ammu,

    Can you please elaborate how can I promote the application name,SP name and MessageID

    Thanks

    Thursday, May 26, 2016 4:02 PM
  • Hi BizTalk1234,

    As you are preferring message based solution we have 2 options to log the responses coming from downstream systems.

    1) Implement WCF costume behavior (Here u will not be able to access the context properties).

    2) implement Receive pipeline components where u can access context properties and you can insert the required fields into your custom DB.

    I prefer option 2 as u need to access few of the custom properties.

    Please mark it as answer if it answered your question.

    Thursday, May 26, 2016 4:05 PM
  • Hi Ammu,

    Is there any links to promote the SPname and application name in receive pipeline.

    Thanks

    Thursday, May 26, 2016 4:12 PM
  • Hi,

    Application name refer: http://biztek.blogspot.in/2007/01/read-your-application-name-in-pipeline.html

    SPName refer: http://esgraham.blogspot.in/

    Note as mentioned previously, BTS.SPName is promoted by the Messaging Engine when publishing a response message from a Solicit-Response send port.

    You can read it like below:

    string strSPName= pInMsg.Context.Read("SPName",
    "http://schemas.microsoft.com/BizTalk/2003/system-properties");

    There are a number of ‘built in’ promoted properties that provide important information.

    All are mentioned here: https://blogs.msdn.microsoft.com/skaufman/2004/10/24/how-to-get-the-source-file-name-in-a-pipeline-component/


    Rachit Sikroria (Microsoft Azure MVP)

    Thursday, May 26, 2016 4:17 PM
    Moderator
  • So we have created the table with columns application name, messageid,formatedxml,SPname So we have to populate all the values to the table.

    Did the client specifically ask for these?  Why create problems for yourself?

    Also realize, you do not need the Application Name since you can derive that from the Send Port Name.  As Send Port can be in one Application only.

    Again, you have to realize the non of these need to be Promoted.  It won't make any difference.

    And keep in mind, all of this is automatically available in Tracking so you're basically doing a lot of work to recreate something that is already exists.  I absolutely guarantee you will create more problems than are solved by doing this.  I've seen it too many times.

    • Marked as answer by BizTalk1234 Monday, May 30, 2016 4:49 PM
    Thursday, May 26, 2016 5:19 PM
    Moderator