-
Notifications
You must be signed in to change notification settings - Fork 44
Submodule phase2‐servlet
A stand alone servlet that takes AS2 requests.
Incoming messages are internally handled via a AS2ServletReceiverModule that MUST be configured in the Configuration file.
Since v4.6.4 it also contains a Servlet to receive asynchronous MDNs.
This sub-project is licensed under the Apache 2 License.
To use this project you have to do the following - all described in more detail below:
- Add the
as2-servletproject as a dependency to your project - e.g. via Maven - Modify your
WEB-INF/web.xmlfile so that it references thecom.helger.phase2.servlet.AS2ReceiveServlet. - Create an AS2 configuration file and store it in a folder that is fully writable to your project. The details of the configuration files are described below.
- Create a key store file (e.g.) called
server-certs.p12located in the same folder as the configuration file. The keystore type must bePKCS12. It must at least contain your private key. The path and the password of the keystore must be set in the AS2 configuration file.
Example WEB-INF/web.xml configuration for the AS2 receive servlet:
<servlet>
<servlet-name>AS2ReceiveServlet</servlet-name>
<servlet-class>com.helger.phase2.servlet.AS2ReceiveServlet</servlet-class>
<init-param>
<param-name>as2-servlet-config-filename</param-name>
<param-value>config/config.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>AS2ReceiveServlet</servlet-name>
<url-pattern>/as2/*</url-pattern>
</servlet-mapping>As you can see, a configuration file called config/config.xml is referenced as an init-param of the servlet.
The name of the init-param must be as2-servlet-config-filename.
Please make sure to insert the correct absolute path to the configuration file inside the param-value element.
In this example the servlet is mapped to the path /as2 meaning that messages must be targeted to this URL (e.g. https://myserver/as2).
To not use the servlet with the file based configuration follow these steps:
- Create a new subclass of
AbstractAS2ReceiveXServletHandlerand overwritecreateAS2Sessionto return theAS2Sessionthat uses the keystore you like. An example can be found in https://github.com/phax/phase2/blob/master/phase2-servlet/src/test/java/com/helger/phase2/servlet/example/AS2ReceiveXServletHandlerCodeConfig.java - Copy the
AS2ReceiveServletto a new class and replace the instantiation ofAS2ReceiveXServletHandlerFileBasedConfigwith the instance of your handler - Reference the new servlet in the
WEB-INF/web.xmlfile
Note: this feature is introduced in v4.6.4
Example WEB-INF/web.xml configuration for the AS2 MDN receive servlet:
<servlet>
<servlet-name>AS2MDNReceiveServlet</servlet-name>
<servlet-class>com.helger.phase2.servlet.mdn.AS2MDNReceiveServlet</servlet-class>
<init-param>
<param-name>as2-servlet-config-filename</param-name>
<param-value>config/config.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>AS2MDNReceiveServlet</servlet-name>
<url-pattern>/as2mdn</url-pattern>
</servlet-mapping>As you can see, a configuration file called config/config.xml is referenced as an init-param of the servlet.
The name of the init-param must be as2-servlet-config-filename.
Please make sure to insert the correct absolute path to the configuration file inside the param-value element.
This is the same file as for the main /as2 servlet
In this example the servlet is mapped to the path /as2mdn meaning that messages must be targeted to this URL (e.g. https://myserver/as2mdn).