本文整理汇总了Java中org.apache.xmlrpc.XmlRpcRequest类的典型用法代码示例。如果您正苦于以下问题:Java XmlRpcRequest类的具体用法?Java XmlRpcRequest怎么用?Java XmlRpcRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlRpcRequest类属于org.apache.xmlrpc包,在下文中一共展示了XmlRpcRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendRequest
import org.apache.xmlrpc.XmlRpcRequest; //导入依赖的package包/类
@Override
public Object sendRequest(XmlRpcRequest req) throws XmlRpcException {
XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) req.getConfig();
URL serverUrl = config.getServerURL();
if (serverUrl == null) {
throw new XmlRpcException("Invalid server URL");
}
try {
con = openConnection(serverUrl);
con.setUseCaches(false);
con.setDoInput(true);
con.setDoOutput(true);
} catch (IOException e) {
throw new XmlRpcException("Failed to create URLConnection: " + e.getMessage(), e);
}
return super.sendRequest(req);
}
示例2: createLegacyApi
import org.apache.xmlrpc.XmlRpcRequest; //导入依赖的package包/类
private JiraLegacyApi createLegacyApi() {
try {
XmlRpcClient client = new XmlRpcClient(getUrl());
Vector<String> parameters = new Vector<String>(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);
}
示例3: createIssueViaXmlRpc
import org.apache.xmlrpc.XmlRpcRequest; //导入依赖的package包/类
@SuppressWarnings("UseOfObsoleteCollectionType")
@NotNull
private String createIssueViaXmlRpc(@NotNull String project, @NotNull String summary) throws Exception {
final URL url = new URL(myRepository.getUrl() + "/rpc/xmlrpc");
final XmlRpcClient xmlRpcClient = new XmlRpcClient(url);
final Map<String, Object> issue = new Hashtable<>();
issue.put("summary", summary);
issue.put("project", project);
issue.put("assignee", myRepository.getUsername());
issue.put("type", 1); // Bug
issue.put("state", 1); // Open
final Vector<Object> params = new Vector<>(Arrays.asList("", issue)); // empty token because of HTTP basic auth
final Hashtable result = (Hashtable)xmlRpcClient.execute(new XmlRpcRequest("jira1.createIssue", params),
new CommonsXmlRpcTransport(url, myRepository.getHttpClient()));
return (String)result.get("key");
}
示例4: writeRequest
import org.apache.xmlrpc.XmlRpcRequest; //导入依赖的package包/类
public void writeRequest(XmlRpcStreamConfig config, XmlRpcRequest request) throws SAXException {
handler.startDocument();
boolean extensions = config.isEnabledForExtensions();
if (extensions) {
handler.startPrefixMapping("ex", org.apache.xmlrpc.serializer.XmlRpcWriter.EXTENSIONS_URI);
}
handler.startElement("", "methodCall", "methodCall", ZERO_ATTRIBUTES);
handler.startElement("", "methodName", "methodName", ZERO_ATTRIBUTES);
String s = request.getMethodName();
handler.characters(s.toCharArray(), 0, s.length());
handler.endElement("", "methodName", "methodName");
handler.startElement("", "params", "params", ZERO_ATTRIBUTES);
int num = request.getParameterCount();
for (int i = 0; i < num; i++) {
handler.startElement("", "param", "param", ZERO_ATTRIBUTES);
writeValue(request.getParameter(i));
handler.endElement("", "param", "param");
}
handler.endElement("", "params", "params");
handler.endElement("", "methodCall", "methodCall");
if (extensions) {
handler.endPrefixMapping("ex");
}
handler.endDocument();
}
示例5: getSelectedRepository
import org.apache.xmlrpc.XmlRpcRequest; //导入依赖的package包/类
private List<Object> getSelectedRepository() throws IOException, XmlRpcException, RepositoryException {
if (selectedRepository == null) {
@SuppressWarnings("unchecked")
List<List<Object>> repoList = (List<List<Object>>) getXmlRpcClient()
.execute(new XmlRpcRequest(handler + ".getAllSpecificationRepositories", toArgs()));
for (List<Object> repo : repoList) {
if (StringUtils.equals(CONFLUENCE + getRepositoryName(), (String) repo.get(REPOSITORY_UID_INDEX))){
selectedRepository = repo;
break;
}
}
if (selectedRepository == null) {
throw new RepositoryException(format("SpecificationRepository %s not found", getRepositoryName()));
}
}
return selectedRepository;
}
示例6: execute
import org.apache.xmlrpc.XmlRpcRequest; //导入依赖的package包/类
/**
* Called when the server is requesting some input from this class.
*/
@Override
public Object execute(XmlRpcRequest request) throws XmlRpcException {
String methodName = request.getMethodName();
if ("RequestInput".equals(methodName)) {
return requestInput();
} else if ("IPythonEditor".equals(methodName)) {
return openEditor(request);
} else if ("NotifyAboutMagic".equals(methodName)) {
return "";
} else if ("NotifyFinished".equals(methodName)) {
finishedExecution.set();
return "";
}
Log.log("Unexpected call to execute for method name: " + methodName);
return "";
}
示例7: execute
import org.apache.xmlrpc.XmlRpcRequest; //导入依赖的package包/类
@Override
public Object execute(final XmlRpcRequest request) throws XmlRpcException {
return execute(new IRequest() {
@Override
public int getParameterCount() {
return request.getParameterCount();
}
@Override
public Object getParameter(int i) {
return request.getParameter(i);
}
@Override
public String getMethodName() {
return request.getMethodName();
}
});
}
示例8: marshal
import org.apache.xmlrpc.XmlRpcRequest; //导入依赖的package包/类
@Override
public void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception {
// need to check the object type
XMLWriter control = getXMLWriter(exchange, stream);
XmlRpcWriter writer = new XmlRpcWriter(xmlRpcStreamRequestConfig, control, typeFactory);
if (graph instanceof XmlRpcRequest) {
writer.writeRequest(xmlRpcStreamRequestConfig, (XmlRpcRequest)graph);
} else {
// write the result here directly
// TODO write the fault message here
writer.write(xmlRpcStreamRequestConfig, graph);
}
}
示例9: toXmlRpcRequest
import org.apache.xmlrpc.XmlRpcRequest; //导入依赖的package包/类
@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;
}
示例10: handleResult
import org.apache.xmlrpc.XmlRpcRequest; //导入依赖的package包/类
@Override
public void handleResult(XmlRpcRequest pRequest, Object pResult) {
LOG.trace("Get the response {}", pResult);
camelExchange.getOut().setHeaders(camelExchange.getIn().getHeaders());
camelExchange.getOut().setBody(pResult);
camelAsyncCallback.done(false);
}
示例11: testRequestMessage
import org.apache.xmlrpc.XmlRpcRequest; //导入依赖的package包/类
@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();
}
示例12: testToXmlRpcRequest
import org.apache.xmlrpc.XmlRpcRequest; //导入依赖的package包/类
@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));
}
示例13: testToXmlRpcRequestWithoutOperationName
import org.apache.xmlrpc.XmlRpcRequest; //导入依赖的package包/类
@Test(expected = TypeConversionException.class)
public void testToXmlRpcRequestWithoutOperationName() throws Exception {
CamelContext context = new DefaultCamelContext();
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setBody(new Object[] {"me", "you"});
exchange.getIn().getBody(XmlRpcRequest.class);
fail("Expect the exception is throw");
}
示例14: sendRequest
import org.apache.xmlrpc.XmlRpcRequest; //导入依赖的package包/类
public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException {
config = (XmlRpcHttpClientConfig) pRequest.getConfig();
URL url = config.getServerURL();
ssl = "https".equals(url.getProtocol());
hostname = url.getHost();
int p = url.getPort();
port = p < 1 ? 80 : p;
String u = url.getFile();
uri = (u == null || "".equals(u)) ? "/" : u;
host = port == 80 ? hostname : hostname + ":" + port;
headers.put("Host", host);
return super.sendRequest(pRequest);
}
示例15: setDocumentAsImplemeted
import org.apache.xmlrpc.XmlRpcRequest; //导入依赖的package包/类
/** {@inheritDoc} */
public void setDocumentAsImplemeted(String location) throws Exception
{
Vector<?> args = CollectionUtil.toVector( username , password, args(URI.create(URIUtil.raw(location))));
XmlRpcClient xmlrpc = getXmlRpcClient();
String msg = (String)xmlrpc.execute( new XmlRpcRequest( handler + ".setSpecificationAsImplemented", args ) );
if(!("<success>".equals(msg))) throw new Exception(msg);
}