View Full Version : webMethods Ezine Writing Custom Handlers for TN and the IS
Questions or comments about this webMethods Ezine article?
Click here (http://www.wmusers.com/ezine/2002jul15_iandrosov_1.shtml) 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!
kmahajan
05-08-2003, 14:23
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
RMG (Unregistered Guest)
05-08-2003, 16:38
Which component you are using (Rosettanet or EDIINT or CIDX)etc..??
kmahajan
05-08-2003, 18:26
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
khazanchi
08-26-2003, 16:41
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.
khazanchi
08-26-2003, 17:03
Hi!
I managed to compile it. Is was wrong on my part. ClassPath setting was giving me problems.
thanx anyway.
sandip
Christian Schuit
09-26-2003, 06:46
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
bart_de_baere
01-20-2004, 09:41
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.
http://www.wmusers.com/wmusers/icons/attachment_icon.gifContentHandler
SignedXMLContentHandler.java (http://www.wmusers.com/wmusers/messages/117/SignedXMLContentHandler-26446.unk) (1.4 k)
bart_de_baere
01-21-2004, 02:53
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.
iandrosov
01-21-2004, 19:52
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
bart_de_baere
01-22-2004, 02:27
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.
iandrosov
01-25-2004, 23:22
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
Nilesh,
did you ever get this custom content handler development guide ? I would be quite interested to get it
thanks
Philippe
Roshan_rec (Unregistered Guest)
11-15-2005, 19:55
Hi,
We are sending documents to our partners through HTTP.
When we tried to send the documents to our
partner through TN, They said the Request
Method was "GET", but they require us "POST".
1. Can webMethods Trading Network configure the "POST" when sending ?
2. If we are sending documents under "GET", how we can change the
Request Method to "POST" ?
Thnaks in advance,
Roshan.
The immediate delivery methods built-in to TN for HTTP/S use the post method, not get. How specifically are you using TN to deliver the data?
Roshan_rec (Unregistered Guest)
11-16-2005, 00:11
Hi Rob,
Thanx for the respone.
We are using HTTP. I am unable to send xml data to my parteners using TN console. I have done all the configuration for parteners info in TN. We are able to get request but unable to send.
We are using webmethod version: 6.1 on Linux.
Is there any patches we need to update?
Thanks in advance.
Regards,
Roshan.
How exactly do you have TN configured to send the documents? How is the processing rule defined? I understand that HTTP is involved but we need to know precisely how you have things set up. The TN delivery methods (that is, when you select "Immediate Delivery" with one of the HTTP options, or "Receiver's Preferred Protocol" and the protocol is HTTP) use HTTP POST. I suspect that you're not using TN delivery and instead are calling a service which is calling pub.client:http with the method parameter set to "get".
Strictly speaking, "TN Console" doesn't send anything. TN Console is the UI to configure TN and view activity. TN itself does the work to send and uses pub.client:http underneath the covers with the method parameter set to "post".
Roshan_rec (Unregistered Guest)
11-20-2005, 22:27
Hi Rob,
Thanx for ur reply. We resolved the above problem. We have one more problem.
Can you please advice us as it is very urgent.
We have 2 WM servers running. Development server (DEV) and Productuon server (Prd). When we are importing the package from DEV server to Prd server, after completing all the imports to Prd server, the Prd server is automatically shutting down. When we tried to restart, Prd server is not starting properly. When we look Prd server logs, it is stopping at " TRANET: Starting webMethods Trading Networks, TRANET: Loading system configuration".
We couldn't able to proceed further. Please let us know mistake where we are doing.
Thanks in advance,
Roshan.
How did you resolve the first problem? It would be helpful for those who come across this same issue in the future and search the forums.
Which package(s) did you migrate from dev to prd? How *exactly* did you migrate the settings? Have you tried an IS restart with the debug level set higher than 4?