none
Processing Flat or Encrypted files in a custom WCF LOB Adapter RRS feed

  • Question

  • Hello.

    I am creating my own custom WCF LOB adapter for a custom send port. (It would work pretty similar but not exactly like a FILE adapter)

    I have used the WCF LOB adapter project in Visual Studio 2010 and gone through the wizard, tweaked the code, updated the machine.config and got the adapter working in my test biztalk application.

    In the AdapterOutboundHander class there is a public Message Execute(Message message, TimeSpan timeout) method to implement my own customer sending process.

    In my scenario, the message parameter would have passed through a pipeline which would either be processed as a flat file (non xml) or PGP encrypted (message would be binary data).

    My issue is it seems like the message parameter to the Execute is expected to be XML.

    Is there anyway I could access the raw message content itself and dump to a file?

    This is needed as if the pipeline configured for this adapter includes PGP encryption the message contents would be not XML parsable but still would need to be sent on via my custom code.

    Thanks for any help!

    Tuesday, December 11, 2012 6:07 AM

Answers

  • Matt,

    I think this is a limitation in the LOB Adapter framework, it expects everything to be in XML when it arrives at the adapter to be sent, you can then control how the message is sent via is set by the encoding selected in the adapter configuration.

    I think you are going to have to use the older Base Adapter Framework to build your adapter, there is a sample in the SDK at c:\program files (x86)\Microsoft BizTalk Server 2010\SDK\Samples\AdapterDevelopment\FileAdapter, there is a solution for design time and run time.  This adapter sample has both receive and send, you should be able to make a copy of this and change the send for your requirements and test to make sure it works the way you expect then clean-up the adapter to be only a send adapter.


    Bill Chesnut | BizTalk Server MVP | Mexia Consulting | Melbourne Australia
    http://www.biztalkbill.com | http://www.mexia.com.au
    Please indicate "Mark as Answer" if this post has answered the question.

    • Marked as answer by MattCorr Tuesday, December 11, 2012 11:06 PM
    Tuesday, December 11, 2012 2:13 PM

All replies

  • Some followup. When I do pass in an encrypted message to my custom Adapter this is the exception I get (before it even gets to the Execute() method):

    System.Xml.XmlException: Invalid character in the given encoding. Line 1, position 1.
       at System.Xml.XmlTextReaderImpl.Throw(Exception e)
       at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
       at System.Xml.XmlTextReaderImpl.InvalidCharRecovery(Int32& bytesCount, Int32& charsCount)
       at System.Xml.XmlTextReaderImpl.GetChars(Int32 maxCharsCount)
       at System.Xml.XmlTextReaderImpl.ReadData()
       at System.Xml.XmlTextReaderImpl.SwitchEncoding(Encoding newEncoding)
       at System.Xml.XmlTextReaderImpl.ParseXmlDeclaration(Boolean isTextDecl)
       at System.Xml.XmlTextReaderImpl.Read()
       at System.Xml.XmlReader.MoveToContent()
       at Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkBodyWriter.ValidateStreamContainsXml(Stream stream)
       at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfMarshaller.CreateWcfMessage(CreateWcfMessageSettings settings)
       at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.SendRequestMessage(IBaseMessage bizTalkMessage, IRequestChannel channel)
       at Microsoft.BizTalk.Adap

    Tuesday, December 11, 2012 6:10 AM
  • Matt,

    I think this is a limitation in the LOB Adapter framework, it expects everything to be in XML when it arrives at the adapter to be sent, you can then control how the message is sent via is set by the encoding selected in the adapter configuration.

    I think you are going to have to use the older Base Adapter Framework to build your adapter, there is a sample in the SDK at c:\program files (x86)\Microsoft BizTalk Server 2010\SDK\Samples\AdapterDevelopment\FileAdapter, there is a solution for design time and run time.  This adapter sample has both receive and send, you should be able to make a copy of this and change the send for your requirements and test to make sure it works the way you expect then clean-up the adapter to be only a send adapter.


    Bill Chesnut | BizTalk Server MVP | Mexia Consulting | Melbourne Australia
    http://www.biztalkbill.com | http://www.mexia.com.au
    Please indicate "Mark as Answer" if this post has answered the question.

    • Marked as answer by MattCorr Tuesday, December 11, 2012 11:06 PM
    Tuesday, December 11, 2012 2:13 PM
  • Thanks for that Bill. 

    I thought that limitation might have been the case if it was was trying to convert to XML before it got my code, but just wanted to be sure. :)

    Tuesday, December 11, 2012 11:07 PM