Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
WritingaCustomContentHandlerforIntegrationServerWiki
webmethods (https://techcommunity.softwareag.com/pwiki//wiki/tag/webmethods/pop_up)
articles (https://techcommunity.softwareag.com/pwiki//wiki/tag/articles/pop_up)
server (https://techcommunity.softwareag.com/pwiki//wiki/tag/integration+server/pop_up)
esb (https://techcommunity.softwareag.com/pwiki//wiki/tag/esb/pop_up)
(https://techcommunity.softwareag.com/pwiki//wiki/tag/custom+content+handler/pop_up)
products (https://techcommunity.softwareag.com/pwiki//wiki/tag/products/pop_up)
esb_and_integration (https://techcommunity.softwareag.com/pwiki//wiki/tag/esb_and_integration/pop_up)
products/pop_up)
integration
sagproducts (https://techcommunity.softwareag.com/pwiki//wiki/tag/sag
esbandintegration (https://techcommunity.softwareag.com/pwiki//wiki/tag/esbandintegration/pop_up)
integrationcloud
(https://techcommunity.softwareag.com/pwiki//wiki/tag/integrationcloud/pop_up)
These cannot be written inside webMethods Developer and need to be written an compiled using your favorite Java IDE, or using the JDK from a commandline. The class files can be
placed in the <IntegrationServer>/packages/<yourpackage>/code/classes directory for easy access from the register and remove services.
The ContentHandler class #
The following is a simple skeleton for this class. This is the class that does all the work.
NOTE: It is not necessary to implement both getInputValues and putOutputValues. Often the putOutputValues method is left empty if the calling client is merely posting a document
and not expecting any specific output.
publicclassMyContentHandlerimplementsContentHandler
{
privateStringcontentType;
publicMyContentHandler()
{
contentType=<default_content_type>;
}
publicMyContentHandler(StringcontentType)
{
this.contentType=contentType;
}
publicStringgetContentType()
{
returncontentType;
}
//thisserviceparsesthereceiveddocumentandcreates//theinputpipelinefortheservicebeinginvoked
publicValuesgetInputValues(java.io.InputStreamis,
InvokeStatestate)
throwsIOException
{
//addcodeheretoreadfromInputStreamandcreatea//Valuesobjectrepresentingthedatacontent
}
//thisserviceparsestheoutputpipelineoftheservice//andconvertsittoastreamformatfordeliveringtothe
//callingclientpublicvoidputOutputValues(OutputStreamos,Valuesout,InvokeStatestate)throwsIOException{//addcodeheretoreadfromtheVal
uesobjectand
//writeitscontentinthedesiredformattothe//OutputStream
}
}
https://techcommunity.softwareag.com/pwiki//wiki/Main/Writing+a+Custom+Content+Handler+for+Integration+Server/pop_up
1/2
2/16/2016
WritingaCustomContentHandlerforIntegrationServerWiki
}
The ContentHandlerFactory class #
The following is all that is needed in the ContentHandlerFactory class.
publicclassMyContentHandlerFactory
extendsContentHandlerFactory
{
privateStringcontentType;
publicMyContentHandlerFactory()
{
contentType="<default_content_type>";
}
publicMyContentHandlerFactory(Stringcontenttype)
{
contentType=contenttype;
}
publicContentHandlercreate()
{
returnnewMyContentHandler(contentType);
}
}
Registering content handlers #
Once the contenttype has been determined using the methods described above, IS will try to invoke a suitable content handler. IS contains a number of standard content handlers,
such as for XML or flat files. Others may have been registered by adapters, eStandards modules or by custom code.
A content handler can be registered at any time while an IS is running by calling
ServerAPI.registerContentHandler(java.lang.Stringcontent_type,
ContentHandlerFactoryfactory)
To this, you provide the contenttype (for example application/vnd.msexcel) and a new instance of com.wm.app.b2b.server.ContentHandlerFactory, like the example above.
NOTE: See the IS Java API documentation for more details on these APIs.
Registering a content handler is best done in a oneline Java service in IS. Then specify that service as a startup service of that package to ensure that the content handler gets
registered each time IS starts up. And to complete the picture you should create a second Java service that removes the content handler again when the package is unloaded:
ServerAPI.removeContentHandler(java.lang.Stringcontent_type)
The information in this document is provided asis and with no warrantywhatsoever. Software AG cannot be held responsible for the results of anyinaccuracies.
0 Attachments (https://techcommunity.softwareag.com/pwiki?
p_p_id=36&p_p_lifecycle=0&p_p_state=pop_up&p_p_mode=view&_36_struts_action=%2Fwiki%2Fview_page_attachments&p_r_p_185834411_nodeName=Main&p_r_p_185834411_title=Writing+a+Custom+Content+Handler+for+Integration+Server&_36_redirect=https%3A%2F%2Ftechcommunity.softwareag.com%2Fpwiki%2F
%2Fwiki%2FMain%2FWriting%2Ba%2BCustom%2BContent%2BHandler%2Bfor%2BIntegration%2BServer%2Fpop_up)
42840 Views
Average (2 Votes)
Comments
https://techcommunity.softwareag.com/pwiki//wiki/Main/Writing+a+Custom+Content+Handler+for+Integration+Server/pop_up
2/2