For this to work you need to implement XmlRpcTransport and override initHttpHeaders method.
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(new URL("http", "localhost", 9000, "")); config.setEnabledForExtensions(true); config.setContentLengthOptional(false); client = new XmlRpcClient(); client.setConfig(config); //implement transport factory XmlRpcTransportFactory xmlRpcTransportFactory = new XmlRpcCommonsTransportFactory(client) { @Override public XmlRpcTransport getTransport() { return new XmlRpcCommonsTransport(this) { @Override protected void initHttpHeaders(XmlRpcRequest pRequest) throws XmlRpcClientException { super.initHttpHeaders(pRequest); //add custom header super.method.addRequestHeader("My-Header", "some header"); } }; } }; client.setTransportFactory(xmlRpcTransportFactory); factory = new ClientFactory(client); //actual method call IMyInterface myHandler = (IMyInterface)factory.newInstance(IMyInterface.class); myHandler.testHeaderMethod("test");For every remote method call, header named My-header will be set to http request.
great, thank you.
ReplyDeleteVery interesting blog. Many blogs I see these days do not really provide anything that attracts others, but believe me the way you interact is literally awesome. You can also check my articles as well.
ReplyDeleteAdmissiongyan, the best German overseas education consultant in Bangalore, since 2012 for study abroad incl. Germany, France, Italy, Sweden, Ireland, NL, or UK.
best overseas consultants in bangalore
ms in mechanical engineering in germany
Masters in Mechanical Engineering in Germany
free education in germany
mba in germany
ms in germany for indian students
study ms in germany
study in germany consultants