Question regarding Content Handler

Hey Gurus,
I never written content handler, but i went through a few posts on wmsusers on content handler and some documentation of webmethods. What I understood from this is , if i submit a file X.tst at url http://abc:5555/serviceY and the target server has content handler for “.tst” file, then the request will be submitted to corresponding content handler first and then it will get submitted to serviceY. is it correct ?

Now my requirement is to develop a content handler which can get the inbound documents of specific content type. and from content handler only i can submit to some custom webmethods service. is it possible ?

To give a pictorial view of my requirements is as follows:

-Partner submits an X.tst document at url http://server:port/serviceY
-My server has content handler to recognize the “.tst” file.
-after the document has been processed by content handler, i want it to submit to another service called “serviceZ”. I don’t want content handler to submit the modified document to serviceY. is it possible ?

Awaiting for your reply.

Regards,
Nilesh

Nilesh,
your understanding is correct.

abt serviceY and serviceZ question - I would like to understand the reasons behind such a requirement.

Do you plan to use the serviceY where the partner submits X.txt and actually invokes serviceY. while an invoke with X.tst invokes contenthandler and then, serviceZ!! is that what you want?

  • Saurabh.

Saurabh,

Thank you very much for prompt response. You got my requirement exactly. Actually We are expecting 4 types of inbound files from partners. (1) application/x-smallfile (2) application/x-largefile (3) application/x-encrypted (4) application/x-decrypted.

So we want to give only one webMethods URL service to all the partners to submit the document regardless of the content type. once document is picked up by content handler, in content handler we have a routing service for that particular content type and further processing in routing service only.

So the question is can I get this functionality ?

Again I will make it more simple to understand:

I wanna give only one URL to all the partners like :

http://server:port/SubmitDataService.

After submission of documents at this URL, my specific content handlers will pick up the files depending upon the content type and inside content handler, i will have the logic to route to some different service other than “SubmitDataService”.

So how can I get this problem resolved ?

Appreciate your help.

Regards,
Nilesh

Nilesh,

Content Handler is not something you invoke yourself. Content Handlers are registered within the IS for a specific Content-Type. Whenever a message with the content type comes in it is run through the Content Handler before the data is passed to the receiving services’ pipeline.

The explanation you gave yourself of a possible implementation seems valid to me. I think the WmSamples package even contains an example of a Content Handler.

HTH,
Jordy

Hey Jordy.
Thanks for explanation. I am totally agree with you. As you told, data will be send to receiving service’s pipeline after content handler’s processing. right ?
Now my requirement is after data has been processed by content handler, whether it is possible that i can submit that data to some other service ? it may be any custom or built-in service. I wanted to submit the data to another service than to the service to which partner has submitted ?
if possible, how can i achieve it ?
What i can think of, can we do some Service.doInvoke from content handler only and submit the data to the service ? or there is another mechanism to submit the data ?

Awaiting for your reply.

Thanks in Advance.
-Nilesh

Nilesh,

Once the data is received by this IS/Content-Handler internally and upon recognizing the content then to this flowservice http://server:port/SubmitDataService inside this you will do parsing logic and futher down the in the flow steps invoke another main service that takes the parsed document as input and process the data to backend as per your requirement says.

If SubmitDataservice is a javaservice then use doInvoke method and push the IDATA pipeline to another main service.

HTH,
RMG.

Nilesh,

I think you will build one or more content handlers each of which will process one or more types of content and return a pipeline which gets passed into the invoked service (SubmitDataService).

What you put into the pipeline is up to you. Your content handler can write the data stream to the file system and pass only the filename to the invoked service. This might be good to consider if you are expecting very large files and need to use Java’s FileOutputStream methods to avoid reading the entire contents of the large file into the JVM memory space. I recently used this approach to process multiple 200Mb files in parallel while only using 3% more of the JVM heap.

At any rate your content handlers could pass only a filename and content type to the SubmitDataService and that service could invoke the appropriate processing service (on a separate thread, if necessary). This invocation could be direct or could be accomplished by publishing a publishable documentType that would be subscribed to by a trigger to invoke the processing service.

Given that you are expecting some large files and some normal files, it might be that the content handlers that address the large files write them to the file system and only pass the file name and content type to the SubmitDataService while the content handler(s) processing the small files do their thing and then populate the pipeline with the transmitted data and the content type.

Good luck,

Mark

Mark,
Thanks for reply.
It seems my problem is similar to what you have already resolved. If you can throw some more light on the solution you used, it will be a great help. I would appreciate if you can post the code of that content handler.

Awaiting for your reply.

Regards,
Nilesh

Nilesh,

The attached example demonstrates one approach for using a FileOutputStream to store a large document to the file system for subsequent processing. This prototype is not (yet) in production. It would be enhanced significantly to be more configurable.

Mark

Streaming content handler example
ContentHandler_TST.java (2.5 k)

Mark,

Thank you very much for all your help. I went through your code and planning to implement the same for my project.

Thanks again.
Thanks to all other wmusers members who helped me to get my issue resolved.

Regards,
Nilesh

Nilesh,

Glad that I could help. Be sure to improve on this example’s crude method of generating unique filenames, to add configurable options where appropriate and to conduct thorough performance testing before implementing these techniques in a production application.

Mark

Mark,

I will do. I would say I have to do. I have to modify the code accordingly to meet my current requirements and to perform thorough testing.

Thanks again.

Regards,
Nilesh