[JAVA] Create XML-RPC API with Wicket



I want to do XML-RPC with Wicket!

Prepare a page for receiving XML-RPC


public class XmlRpcPage extends WebPage {

	private static final long serialVersionUID = 1L;

	public XmlRpcPage(PageParameters params) {

		HttpServletRequest request = (HttpServletRequest)getRequestCycle().getRequest().getContainerRequest();
		HttpServletResponse response = (HttpServletResponse)getRequestCycle().getResponse().getContainerResponse();

		getRequestCycle().replaceAllRequestHandlers(new IRequestHandler() {

			public void respond(IRequestCycle requestCycle) {
				try {
					processXmlRpcRequest(request, response);
				} catch (ServletException | IOException e) {
					throw new WicketRuntimeException(e);

			public void detach(IRequestCycle requestCycle) {



	 * Get XML-RPC server
	 * @return
	protected XmlRpcServletServer getXmlRpcServer() {
		return ((WicketApplication)getApplication()).getXmlRpcServer();

	 * Process XML-RPC request
	 * @param request
	 * @param response
	 * @throws ServletException
	 * @throws IOException
	protected void processXmlRpcRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
		getXmlRpcServer().execute(request, response);

	public Markup getAssociatedMarkup() {
		return null;

	protected void configureResponse(WebResponse response) {
		final String encoding = getApplication().getRequestCycleSettings().getResponseRequestEncoding();
		response.setContentType("application/xhtml+xml; charset=" + encoding);

Wicket application settings


	protected XmlRpcServletServer xmlRpcServer	= null;
	protected XmlRpcServerConfigImpl xmlRpcConfig	= null;

	public WicketApplication() {
		xmlRpcServer = new XmlRpcServletServer();
		xmlRpcConfig = new XmlRpcServerConfigImpl();


	 * Initialize xmlrpc server
	public void initXmlRpc() {

		/* configure xml-rpc server */
		xmlRpcServer.setTypeFactory(new CustomTypeFactory(xmlRpcServer));

		//CustomTypeConverterFactory is Xml-Factory for type conversion with Rpc
		xmlRpcServer.setTypeConverterFactory(new CustomTypeConverterFactory());

		xmlRpcConfig = (XmlRpcServerConfigImpl)this.xmlRpcServer.getConfig();

		PropertyHandlerMapping mapping = createXmlRpcHandlerMapping();


	 * XML-Property handler map generation for RPC
	 * @return
	private PropertyHandlerMapping createXmlRpcHandlerMapping() {

		PropertyHandlerMapping mapping = new PropertyHandlerMapping();
		mapping.setRequestProcessorFactoryFactory(new StatelessProcessorFactoryFactory());
		mapping.setTypeConverterFactory(new CustomTypeConverterFactory());
		try {
			mapping.load(getClass().getClassLoader(), "xmlrpc.properties");
		} catch (XmlRpcException | IOException e) {
			StringWriter sw = new StringWriter();
			e.printStackTrace(new PrintWriter(sw));
			throw new WicketRuntimeException(e);
		return mapping;




		// initialize XML-RPC


		// xml-rpc base
		mount(new MountedMapper("/XmlRpc", XmlRpcPage.class));



	public static void main(String[] args) throws Exception {
		XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
		config.setServerURL(new URL("http://localhost:8080/sample/XmlRpc"));

		XmlRpcClient client = new XmlRpcClient();
		client.setTransportFactory(new XmlRpcLoggingTransportFactory(client));
		client.setTypeFactory(new CustomTypeFactory(client));

		Vector<Object> arg = new Vector<Object>();

		Object response = client.execute("SampleService.sampleMethod", arg);
		System.out.println("Response: " + response);


If you have any questions, please feel free to contact us. For error handling, try ~ catch catches everything and returns the result as a return value. (I thought I'd write it later, but it wasn't something I bothered to write ...)

Recommended Posts

Create XML-RPC API with Wicket
Create an RSA encryption-enabled JSON API with wicket
Create cool API specifications with Micronaut + Swagger UI
Create a web api server with spring boot
Try create with Trailblazer
Test Web API with junit
Avoid serializing pages with Wicket
Use Bulk API with RestHighLevelClient
[Rails] Create API to download files with Active Storage [S3]
API creation with Rails + GraphQL
Create a playground with Xcode 12
Create a SlackBot with AWS lambda & API Gateway in Java
REST API testing with REST Assured
Link API with Spring + Vue.js
Create microservices with Spring Boot
Create a restaurant search app with IBM Watson + Gurunavi API (with source)
Create an immutable class with JAVA
Create a Vue3 environment with Docker!
Create PDF with itext7-Free layout: Text-
Spring with Kotorin --4 REST API design
Automatic API testing with Selenium + REST-Assured
Let's create Ubuntu environment with vmware
Create an app with Spring Boot 2
Create RUNTEQ's environment with Windows DockerDesktop
REST API test with REST Assured Part 2
Create PDF with itext7-Free layout: Table-
Create pagination function with Rails Kaminari
Micro benchmark made with JFR API
Create SolrCloud verification environment with Docker
Create an excel file with poi
Create an easy-to-extend Stream API alternative
Create an app with Spring Boot
Create two DatePickers linked with TextField
Create Laravel environment with Docker (docker-compose)
Create command line app with maven
Create PDF with itext7 ~ Hello World ~
Create My Page with Rails devise
Create exceptions with a fluid interface
FileUpload with Rest on Apache Wicket
Create a Maven project with a command
Create a SPA with authentication function with Rails API mode + devise_token_auth + Vue.js 3 (Rails edition)