use of org.apache.xmlrpc.XmlRpcRequest in project dubbo by alibaba.
the class XmlRpcProtocol method doExport.
@Override
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
final URL httpUrl = url.setProtocol("http");
String addr = httpUrl.getIp() + ":" + httpUrl.getPort();
ProtocolServer protocolServer = serverMap.get(addr);
if (protocolServer == null) {
RemotingServer remotingServer = httpBinder.bind(httpUrl, new InternalHandler(httpUrl.getParameter("cors", false)));
serverMap.put(addr, new ProxyProtocolServer(remotingServer));
}
final String path = httpUrl.getAbsolutePath();
XmlRpcServletServer xmlRpcServer = new XmlRpcServletServer();
PropertyHandlerMapping propertyHandlerMapping = new PropertyHandlerMapping();
try {
propertyHandlerMapping.setRequestProcessorFactoryFactory(new RequestProcessorFactoryFactory() {
@Override
public RequestProcessorFactory getRequestProcessorFactory(Class pClass) throws XmlRpcException {
return new RequestProcessorFactory() {
@Override
public Object getRequestProcessor(XmlRpcRequest pRequest) throws XmlRpcException {
return impl;
}
};
}
});
propertyHandlerMapping.addHandler(XmlRpcProxyFactoryBean.replace(type.getName()), type);
} catch (Exception e) {
throw new RpcException(e);
}
xmlRpcServer.setHandlerMapping(propertyHandlerMapping);
XmlRpcServerConfigImpl xmlRpcServerConfig = (XmlRpcServerConfigImpl) xmlRpcServer.getConfig();
xmlRpcServerConfig.setEnabledForExceptions(true);
xmlRpcServerConfig.setContentLengthOptional(false);
skeletonMap.put(path, xmlRpcServer);
return new Runnable() {
@Override
public void run() {
skeletonMap.remove(path);
}
};
}
use of org.apache.xmlrpc.XmlRpcRequest in project camel by apache.
the class XmlRpcConverterTest method testToXmlRpcRequest.
@Test
public void testToXmlRpcRequest() throws Exception {
CamelContext context = new DefaultCamelContext();
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setHeader(XmlRpcConstants.METHOD_NAME, "greet");
exchange.getIn().setBody(new Object[] { "me", "you" });
XmlRpcRequest request = exchange.getIn().getBody(XmlRpcRequest.class);
assertNotNull("The request should not be null", request);
assertEquals("Get a wrong operation name", "greet", request.getMethodName());
assertEquals("Get a wrong parameter size", 2, request.getParameterCount());
assertEquals("Get a worng parameter", "you", request.getParameter(1));
}
use of org.apache.xmlrpc.XmlRpcRequest in project camel by apache.
the class SpringXmlRpcDataFormatTest method testRequestMessage.
@Test
public void testRequestMessage() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:request");
mock.expectedMessageCount(1);
XmlRpcRequest result = template.requestBody("direct:request", new XmlRpcRequestImpl("greet", new Object[] { "you", 2 }), XmlRpcRequest.class);
assertNotNull(result);
assertEquals("Get a wrong request operation name", "greet", result.getMethodName());
assertEquals("Get a wrong request parameter size", 2, result.getParameterCount());
assertEquals("Get a wrong request parameter", 2, result.getParameter(1));
assertMockEndpointsSatisfied();
}
use of org.apache.xmlrpc.XmlRpcRequest in project camel by apache.
the class XmlRpcConverter method toXmlRpcRequest.
@Converter
public static XmlRpcRequest toXmlRpcRequest(final Object[] parameters, Exchange exchange) {
// get the message operation name
String operationName = exchange.getIn().getHeader(XmlRpcConstants.METHOD_NAME, String.class);
// create the request object here
XmlRpcRequest request = new XmlRpcRequestImpl(operationName, parameters);
return request;
}
use of org.apache.xmlrpc.XmlRpcRequest in project intellij-community by JetBrains.
the class JiraRepository method createLegacyApi.
private JiraLegacyApi createLegacyApi() {
try {
XmlRpcClient client = new XmlRpcClient(getUrl());
Vector<String> parameters = new Vector<>(Collections.singletonList(""));
XmlRpcRequest request = new XmlRpcRequest("jira1.getServerInfo", parameters);
@SuppressWarnings("unchecked") Hashtable<String, Object> response = (Hashtable<String, Object>) client.execute(request, new CommonsXmlRpcTransport(new URL(getUrl()), getHttpClient()));
if (response != null) {
myJiraVersion = (String) response.get("version");
}
} catch (Exception e) {
LOG.error("Cannot find out JIRA version via XML-RPC", e);
}
return new JiraLegacyApi(this);
}
Aggregations