webMethods Ezine Writing Custom Handlers for TN and the IS

Questions or comments about this webMethods Ezine article?

Click here to read the original text.

I found Igor’s advice on IS memory related issues and the com.wm.app.b2b.server.* to be extremely educational.

Excellent article!

How do I write content handler for the posting where header data ( mime types) are more then one. Example

Content-type: text/plain
From: ABCCustomer
To: SomePartner

This is the payload for processing

In this case if I write content handler just for text/plain how do I get values From and TO to be passed to the service being invoked. Any insight would be greatly appreciated. Example would be perfect.

Khushhal

Which component you are using (Rosettanet or EDIINT or CIDX)etc…??

RMG

I am using EDIINT component. But problem is that we are moving data through a proxy server ( which is webmethods server) . This works for rosettanet since content type is only aplication/x-rosettanet-agent and mime does not have other values and we have written our own content handler for that and while httping to the customer we hardcode content-type and it works but EDIINT has several values in header and I want to be able to pick all values so that I could pass those to the http and same is true while inbound.

Khushhal
Thanks

Hi! Dan,

Taking into consideration the content handler article, i am trying to implement the same. When i am trying to compile the TXTContentHandler.java, it is not able to get the jar for the InvokeState class.

Is it that this can only be done when the server is running. I am trying to do this from a client machine, after copying the server.jar from the server.

server.jar contains the InvokeState class.

Please suggest.

Hi!

I managed to compile it. Is was wrong on my part. ClassPath setting was giving me problems.

thanx anyway.

sandip

Hi

Build the content handler (for multipart/form-data), and the factory, installed them, registered the handler, and then… everything seems to work fine except for 2 things:

  1. The browser I use to submit a file gives me a “save/open” dialogue after submission(?)
  2. No data is to be located in the pipeline, where it should have been put by the content handler.

I’m running wM IS 6.0.1 SP1 & using MSIE 6+ to submit the file. Can you tell me if there is any other resource for creating content handlers? I already went through Advantage and WmUsers.

Thanks

Hi,
I’m trying to replace WebMethods default content type (“application/x-www-form-urlencoded”) with a new content handler I built.Everything seems to work fine with unregister and register of the handler but when a service is invoked only the method “putOutputValues” is called, the method “getInputValues” is never called.

Any idea about this ?

Thanks

Hi again,
I´ve one more doubt :
When a service is invoked via URL like ("http://host:port/invoke/service_path?input1=xxx&input2=yyy") what is the content-type associated ? “text/html” or “application/x-www-form-urlencoded” ?

Thanks

Hi,
After some more investigations and tests I saw that if I invoked a service via HTTP with POST the method “getInputValues” of the ContentHandler is called but is not called if service is invoked with HTTP GET.

Anybody know the reason for this ?

Thanks

Hi,

I know this post is pretty old, but therefore not unimportant. It took me a while to figure this all out and I still have a question:

I wrote the example code of Igor in jcode and fragged everything with jcode. I got no compile errors, but my ContentHandler doesn’t get “written” while my ContentHandlerFactory and the create JavaService does!

So I see the ContentHandlerFactory with the create JavaService in the Developer, but not the ContentHandler.

When I shutdown the IS and restart it the package only gets partially reloaded, so I figure the ContentHandler needs to be written.

Attached is my java code for the ContentHandler, does anyone see something wrong with it?

Thx
B.

ContentHandler
SignedXMLContentHandler.java (1.4 k)

Hi,

I have good news, there is nothing wrong with the code I posted!

We ran the service again, even without physically seeing the ContentHandler in wm Developer and with a partially loaded package and it works!

Still I would like to now why I can’t see the content handler in wm Developer and why the package only gets partially loaded. Is it because the content handler class implements an interface?

Anybody got a clue?

Thx
B.

Hi Bart I saw this post and wanted to clarify couple of things. First of all ContentHandler and ContentHandlerFactory are classes that are not intended to be used as WM java service directly. They are classes that will be used by IS to process incoming data with your custom registered type. The only services you do need to expose to Developer are really only registration and unregistration. Becasue these services need to be used as package startup and shutdown services respectively. This is to make it conviniet for use. As package loaded or reloaded your new content handler will be registered or unregistered along with the data type. You can see clear example use of this in WM samples package. My article did not discuss Unregitering content handler as its not important for overall functionality of the handler. But its really easy services to create 1 line Java code: ServerAPI.removeContentHandler(“Content/type”); That is it for unregistering.
Another fact is if you look at methods that ContentHandler and ContentHandlerFactory provides you will find that Input/output for these are more like regular Java methods instead on WM service. Therefore if you did expose them as driect services in Developer you will not be able to pass data as IData or Values objects to them directly.
Since you did frag them and try to expose all that code as services but some of it not shown in your developer. I can only speculate why it may have hapened without seeing your full package. If you want me to look at it you are welcome to send me your package and I may be able to explain why things did not show up as you expect them to. Even though they are not suposed be use this way.

Now if you did wanted to use you content handler code as a service you can place it in a java service and my article discusses that option as Custom Content Handlers. Although its not really a Contenthandler more of a custom Java service that can porcess custom type of data incoming directly to the service. That data will bypass all standard IS handlers.

Hope this clears things for you

Hi Igor,

Thanx for your answer.

I solved my problem by deleting the jcode tags in my two classes (ContentHandler and ContentHandlerFactory) as you say in your answer they are classes and not services so they don’t need to be exposed hence, you don’t see them (but they are there). Thanx for clearing this up.

I wrote the register and unregister java services (with jcode tags) and these work perfectly! I can see them in my package.

It seems that your example in the ezine was completely correct, I only didn’t know how to implement it as I never worked with the jcode before. But I have succeeded now.

I have a new question for you: Is it possible to make a custom handler
that takes in to account the content/type, but also the protocol?

Thanx a million for your answer and example.
B.

Bart not sure why you need handler to use protocol information? Normally handler is invoked after listener got the portocol and soket data passed to handler as strem to parse it. But if you must know there is object InvokeState passed into your Handler’s Java method. From that object you can get all current info about invokation of your service such as session, user, socket object, content encoding and more check WM API docs on InvokeState object. Among those you can find API getProtocolInfoif() it returns com.wm.app.b2b.server.ProtocolInfoIf its not documented class but you may get portocol info from it using String getProtocolPropertyList() and getProtocolProperty(String). Although I do not see why you need such low level details about invoke protocol inside your handler?
Hope this is helpfull.

Hi,

I have a situation that needs to be addressed with the help of a custom Content Handler. The situation we are having is that the client sends us data via an HTTP Post ( the protocol they use is RFC 1867). While receiving in our system we are missing the ‘NAME’ attribute and hence the data is split into 2 parts - the first part going to the ‘NAME’ field and the part going to the Value field. We need to be able to pass the entire data in the Value field.
Has anybody come across this. Any help is highly appreciated.

Thanks
Surresh

Hi IGOR,

How are you doing ?

Actually i have a requirement to handle large inbound
documents to IS/TN. I have read your article about ‘Custom Conent
Handlers’. But actually i havent developed a single content handler
so i dont know how to start. If you guide me where can i get step by
step guide to create and use custom content handler, it would be a
great help.

My requirement is to get the inbound file, identify it . The inbound
file is always PGP entrypted, so decrypt it first and check the file
size. And if it is a large file, then handle it by some efficient way
without any or little performance cost.

Thanks in Advance.

If other folks, can throw light on this post, u r always welcome.

Regards,
Nilesh

Nilesh,

For handling large files routing to TN there is documentation available for TN LargeDoc handling.

Please get this pdf from Advantage site and it explanis well how to configure and setup.

HTH,
RMG.

Thanks RMG for prompt response.

But my requirement is litter different. We have requirement first to get inbound documents submitted to IS ,then decrypt them, check the size of the document and decide whether its large. After performing this operation, we want to submit those document to TN. So it goes like this:

Partner FTPs document to IS Service --> IS Service decrypts it, checks the file size and decides whether doc is large --> Submit the document to TN.

What do u suggest in this scenario ? Should we develop a custom content handler ? so all the documents inbound to IS will be submitted to a single service …( you can consider that service as a gateway to IS ) …

Regards,
Nilesh