Working with getTransportInfo contents

I have searched through these forums and found a lot of postings, but nothing I have tried after reading them is working for me. I am missing a piece or two.
The scenario: I have an e-mail port to which people will send documents as e-mail attachments. The senders will vary as will the documents and document types. The ultimate goal is to use webMethods to receive these external documents then move them to our internal servers, file shares, etc.
I have created a service which uses the getTransportInfo utility to identify sender, attachment file name, file type, etc. All fine and good. But, I can’t do anything with the attachment, yet. The attachment contents are shown as How do I work with this? causes a classcastexception error. and cause other errors.
What steps am I missing?

It seems to be query specific to Java. Its about converting byteArrayInputStream to String in Java and there is no specific utility provided by webMethods for the same.

The implementation of your service should change in a way to handle all content types of the attachments.

  1. Suppose the user sends a text file as an attachement then the wm receives it as byte array in which case you can use streamToString.
  2. If the attachment is an XML file then you should define a ‘node’ in the input signature and do xmlNodeToDocument because the content is text/xml and wm receives it as a node.

You can examine the string 'Email/contentType’ of getTransportParams for the type of document thats being sent as an attachment. So you can either process pre defined file extensions and leave others or create your own content handlers for other documents (pdf, XLS, doc etc)
Hope this helps.


Thank you for the input! I have tried to use streamToBytes then bytesToString without success, always getting at least a ClassCastException. Why wouldn’t these utilities work?

You will get a class cast exception when wrong input is provided. Isn’t it? For information, what type of file have you sent as an attachment?
Try sending a flat file data in a textfile (xxxyyy.txt) and take an input parameter ‘ffdata’ of type ‘unknown’ and map this to the input of streamToBytes service. Your sequence should work this time.
I have a similar program thats working fine which receives a flatfile data in the form of a text file on wm6.5.


I’ve tried suggestions here and I still get errors and cannot do a thing with my attachments. I am missing something, but I don’t know what!!

I am new to webMethods, so my next question may be silly but…
when you suggest creating an input parameter named “ffdata” of type “unknown”…how do I do that? From what I see, I can create input parameters of specific types: string, document, document reference, object, etc.

I have tried sending a .txt file, mapping “contents” to an object, then mapping the object to the streamToBytes. Still get class cast exception.

I have tried mapping the “contents” to the streamToString service. Still get class cast exeption with that.

Regardless of the format of the attachment (pdf, txt, etc), the contents are described as I need to convert this to something meaningful in order to move the file and its contents, intact, through the pipeline and out. What am I missing???

I am attaching my package thats working fine. Have a look at it and you may get some insight of where you made a mistake. The service in the package handles only xml and text file attachments.

Restore pipeline doesn’t work here (before doing some manipulation on byteArrayStream) as the content stream is context dependent. I did it on wm6.5

Guna (8.23 KB)

Guna -

Thanks for the package! Now, I need to know how to interpret it. I have opened and viewed the zip file, and viewed the files within. By doing that, I can’t tell, precisely, what you are doing. I don’t know how to load a zip file into webMethods Developer…as a package?
I’m still stuck where I was. Any further insight would be greatly appreciated!

Install the package by copying the zip file into ‘replicate/inbound’ folder and installing it through admin console:Packages > Management > Install Inbound Releases’

Now you have to reconfigure your webMethods email port to invoke the service: rbemailattachments.subflows:receiveEmail in this new package, whenever an email comes. Its just changing the ‘Default service’ in the port configuration. See the image I attached.


Although this is a very old post, it helped me out! In 2018.

Thanks a lot, really helpful.