none
Send file name from biztalk to wcf service

    Question

  • I created a biztalk application. Using this application, i am reading the xml file and communicating to WCF service for further process. Can anyone help me to send the xml file name as well with its content. I created a schema, it has only xml data not file name.

    Thanks

    Tuesday, October 08, 2013 11:27 AM

Answers

  • Sure, that's the easier path then.

    You will have to add a field to the message you are sending to the service.

    Once you've done that, you can set it as a Distinguished Field to make it easily accessible in an Orchestration.

    When you receive with the File Adapter, the FILE.ReceivedFileName is set so in the Orchestration, you use syntax similar to this:

    MyMessage.MessageRoot.MyFileNameField = MyIncomingMessage(FILE.ReceivedFileName)

    One thing to note, this assumes the Distinguished Field element already exists, with any value, in the MyMessage.

    • Marked as answer by mdew12 Wednesday, October 09, 2013 1:49 PM
    Tuesday, October 08, 2013 3:10 PM
  • Hope you have all the information required, if the field you want is not promoted, then you can use Xpath in message assignment shape.

    xpath(Outmsg, "//XpathForField") = Inmessage.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties");



    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.


    Wednesday, October 09, 2013 12:55 PM

All replies

  • If the requesting service does not have a mechanism to accept the filename how can you even devise a mechanism to do so? If you're the author of the service the change the service contract to accept the filename also and then call it.

    Regards.

    Tuesday, October 08, 2013 12:04 PM
  • refer Article, How to consume service inside orchestration .

    you can use Map to send data to service .

    use FILE.ReceiveFileName to receive file name and assign to corresponding field.

    Tuesday, October 08, 2013 12:18 PM
  • Hi mdew12,

    In integration using service like WCF, you not sending the physical file across to your destination system. You’re sending the service contract. So in your WCF service contract you shall have field/data contract to accept the received file name. If so, then while constructing the service contract you can pass the received file name by access the context of the received message

    message.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties");

    FYI, ReceivedFileName property is populated to the context of the received message, if you use receive adapters like File, FTP


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.

    Tuesday, October 08, 2013 12:42 PM
  • First question, how does the service expect to receive the filename field? As part of the Header or is it in the Message content?
    Tuesday, October 08, 2013 1:18 PM
  • Hi boatseller,

    Approach can be anything Header or in message content. I will prefer the name should comes with message content.

    Please let me know both approach.

    Thanks in advance


    • Edited by mdew12 Tuesday, October 08, 2013 2:50 PM
    Tuesday, October 08, 2013 2:50 PM
  • If you want to set the ReceiveFileName

    In SOAP header:

    When using the WCF Adapters, SOAP Headers are defined with the built-in WCF.OutboundCustomHeaders context property. So for example, in your orchestration while constructing the outbound message

    outboundmsg(WCF.OutboundCustomHeaders)  =  "<tns1:RcvdFileName xmlns:tns1='http://tns1'>" + Inmessage.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties"); +"</tns1:RcvdFileName>"

    In Message content:

    You should have filed/data contract to contain the Received file name. If this field is promoted,

    Outboundmsg.RcvDFileName = Inmessage.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties");

    Otherwise use Xpath to assgin the value from “Inmessage.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties");”


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.


    Tuesday, October 08, 2013 3:03 PM
  • I have few questions:

    You are consuming WCF service right?

    Does the data contract has container for file name?

    Are you creating the service and then consuming it?



    I hope this helps!!!!!!

    Maheshkumar S. Tiwari|BizTalk Developer Interview Questions and Answers

    http://tech-findings.blogspot.com/


    Tuesday, October 08, 2013 3:08 PM
  • Sure, that's the easier path then.

    You will have to add a field to the message you are sending to the service.

    Once you've done that, you can set it as a Distinguished Field to make it easily accessible in an Orchestration.

    When you receive with the File Adapter, the FILE.ReceivedFileName is set so in the Orchestration, you use syntax similar to this:

    MyMessage.MessageRoot.MyFileNameField = MyIncomingMessage(FILE.ReceivedFileName)

    One thing to note, this assumes the Distinguished Field element already exists, with any value, in the MyMessage.

    • Marked as answer by mdew12 Wednesday, October 09, 2013 1:49 PM
    Tuesday, October 08, 2013 3:10 PM
  • Maheshkumar S

    I have an existing wcf service and consuming it from biztalk application. there is no field in data contract to contain the file name. I have no issues to add new field for the same.



    • Edited by mdew12 Tuesday, October 08, 2013 3:32 PM
    Tuesday, October 08, 2013 3:11 PM
  • Well then , you can go ahead with the suggestions from boatseller and Ashwin.


    I hope this helps!!!!!!

    Maheshkumar S. Tiwari|BizTalk Developer Interview Questions and Answers

    http://tech-findings.blogspot.com/


    Wednesday, October 09, 2013 8:51 AM
  • boatseller and Ashwin, Thanks for your assistance on.

    I am using .btm file to map xml schema and wcf service. Can I specify filename here?

    THanks in advance

    Wednesday, October 09, 2013 12:35 PM
  • You will have to use Message Assignment shape after Map.

    then as suggested above do following:

    OutMessage.FileNameField = IncomingMessage(FILE.ReceivedFileName)

    Also have look at following blog post for better understanding:

    http://masteringbiztalkserver.wordpress.com/tag/change-the-output-file-name/



    I hope this helps!!!!!!

    Maheshkumar S. Tiwari|BizTalk Developer Interview Questions and Answers

    http://tech-findings.blogspot.com/


    Wednesday, October 09, 2013 12:41 PM
  • Hi mdew,

    If you understood my earlier comments, ReceivedFileName property is populated to the context of the received message, if you use receive adapters like File, FTP.

    • If you just use map (message only), then in map, you can use ContextAccessor Functoid  from codeplex (third party) to access these properties from the context of the message.
    • or if you invoke the map in orchestration, then after map you can construct the message to have ReceivedFileName in message assignment shape.  If this field is promoted,
    Outboundmsg.RcvDFileName = Inmessage.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties");

    Otherwise use Xpath to assign the value from “Inmessage.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties");”


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.


    Wednesday, October 09, 2013 12:42 PM
  • I am already using Message assignment shape to modify message header.

    I have only MsgWCF.parameters, no other property. how can i update it.

    Wednesday, October 09, 2013 12:49 PM
  • Hope you have all the information required, if the field you want is not promoted, then you can use Xpath in message assignment shape.

    xpath(Outmsg, "//XpathForField") = Inmessage.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties");



    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.


    Wednesday, October 09, 2013 12:55 PM