当前位置: 首页>>代码示例>>Java>>正文


Java ContentExchange.getResponseContent方法代码示例

本文整理汇总了Java中org.eclipse.jetty.client.ContentExchange.getResponseContent方法的典型用法代码示例。如果您正苦于以下问题:Java ContentExchange.getResponseContent方法的具体用法?Java ContentExchange.getResponseContent怎么用?Java ContentExchange.getResponseContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.client.ContentExchange的用法示例。


在下文中一共展示了ContentExchange.getResponseContent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sentGetRequest

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
public static String sentGetRequest(final String url) throws Exception {
    HttpClient httpClient = new HttpClient();
    try {
        httpClient.start();
        ContentExchange contentExchange = new ContentExchange();
        contentExchange.setMethod("GET");
        contentExchange.setRequestContentType(MediaType.APPLICATION_JSON);
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        contentExchange.setURL(url);
        httpClient.send(contentExchange);
        contentExchange.waitForDone();
        return contentExchange.getResponseContent();
    } finally {
        httpClient.stop();
    }
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:17,代码来源:RestfulTestsUtil.java

示例2: readExchangeCallLog

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
static CallLog[] readExchangeCallLog(ObjectMapper mapper, ContentExchange exchange) {
  try {
    exchange.waitForDone();
    String responseJson = exchange.getResponseContent();
    return mapper.readValue(responseJson, CallLog[].class);
  } catch (Exception e) {
    return new CallLog[0];
  }
}
 
开发者ID:holdenk,项目名称:learning-spark-examples,代码行数:10,代码来源:ChapterSixExample.java

示例3: login

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
public static String[] login(String username, String password, String url)
        throws Exception, InterruptedException, SAXException,
        ParserConfigurationException {
    HttpClient client = new HttpClient();
    client.setTimeout(10000);
    client.setConnectTimeout(5000);
    client.start();

    ContentExchange exchange = new ContentExchange();
    exchange.setMethod("POST");
    exchange.setURL(new URL(url + getSoapUri()).toExternalForm());
    exchange.setRequestContentSource(new ByteArrayInputStream(soapXmlForLogin(
            username, password)));
    exchange.setRequestHeader("Content-Type", "text/xml");
    exchange.setRequestHeader("SOAPAction", "''");
    exchange.setRequestHeader("PrettyPrint", "Yes");

    client.send(exchange);
    exchange.waitForDone();
    String response = exchange.getResponseContent();

    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
    SAXParser saxParser = spf.newSAXParser();

    LoginResponseParser parser = new LoginResponseParser();
    saxParser.parse(new ByteArrayInputStream(
            response.getBytes("UTF-8")), parser);

    if (parser.sessionId == null || parser.serverUrl == null) {
        System.out.println("Login Failed!\n" + response);
        return null;
    }

    URL soapEndpoint = new URL(parser.serverUrl);
    StringBuilder endpoint = new StringBuilder()
            .append(soapEndpoint.getProtocol())
            .append("://")
            .append(soapEndpoint.getHost());

    if (soapEndpoint.getPort() > 0) endpoint.append(":")
            .append(soapEndpoint.getPort());
    return new String[]{parser.sessionId, endpoint.toString()};
}
 
开发者ID:AlgeFramework,项目名称:alge-core,代码行数:45,代码来源:SoapLoginUtil.java


注:本文中的org.eclipse.jetty.client.ContentExchange.getResponseContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。