當前位置: 首頁>>代碼示例>>Java>>正文


Java PutMethod.setRequestBody方法代碼示例

本文整理匯總了Java中org.apache.commons.httpclient.methods.PutMethod.setRequestBody方法的典型用法代碼示例。如果您正苦於以下問題:Java PutMethod.setRequestBody方法的具體用法?Java PutMethod.setRequestBody怎麽用?Java PutMethod.setRequestBody使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.httpclient.methods.PutMethod的用法示例。


在下文中一共展示了PutMethod.setRequestBody方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Put

import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
/**
 * This method implements the HTTP Put Method
 * 
 * @param uri
 *            Resource URI
 * @param requestPayload
 *            Content which has to be put into the Resource
 * @return ResponseCode of HTTP Interaction
 */
@SuppressWarnings("deprecation")
public static HttpResponseMessage Put(String uri, String requestPayload,
		String acceptHeaderValue) {

	PutMethod method = new PutMethod(uri);
	// requestPayload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
	// requestPayload;

	HighLevelRestApi.setAcceptHeader(method, acceptHeaderValue);
	method.setRequestBody(requestPayload);

	HttpResponseMessage responseMessage = LowLevelRestApi
			.executeHttpMethod(method);

	// kill <?xml... in front of response
	HighLevelRestApi.cleanResponseBody(responseMessage);

	return responseMessage;
}
 
開發者ID:nyuuyn,項目名稱:chef4bpel,代碼行數:29,代碼來源:HighLevelRestApi.java

示例2: putFile

import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
public static void putFile(HttpClient client, 
                           HttpURL url, 
                           InputStream is,
                           String contentType,
                           String lockToken)
   throws IOException, HttpException
{
   PutMethod put = new PutMethod(url.getURI());
   generateIfHeader(put, lockToken);
   put.setRequestHeader("Content-Type", contentType);
   put.setRequestBody(is);
   put.setFollowRedirects(true);
   int status = client.executeMethod(put);
   switch (status) {
      case WebdavStatus.SC_OK:
      case WebdavStatus.SC_CREATED:
      case WebdavStatus.SC_NO_CONTENT:
         return;
      default:
         HttpException ex = new HttpException();
         ex.setReason(put.getStatusText());
         ex.setReasonCode(status);
         throw ex;
   }
}
 
開發者ID:integrated,項目名稱:jakarta-slide-webdavclient,代碼行數:26,代碼來源:Utils.java

示例3: putMethod

import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
/**
 * Execute the PUT method for the given path.
 *
 * @param path the server relative path to put the data
 * @param data The byte array.
 * @return true if the method is succeeded.
 * @exception HttpException
 * @exception IOException
 */
public boolean putMethod(String path, byte[] data)
    throws HttpException, IOException {

    setClient();
    PutMethod method = new PutMethod(URIUtil.encodePathQuery(path));
    generateIfHeader(method);
    if (getGetContentType() != null && !getGetContentType().equals(""))
        method.setRequestHeader("Content-Type", getGetContentType());

    method.setRequestHeader("Content-Length", String.valueOf(data.length));
    method.setRequestBody(new ByteArrayInputStream(data));

    generateTransactionHeader(method);
    int statusCode = client.executeMethod(method);

    setStatusCode(statusCode);
    return (statusCode >= 200 && statusCode < 300) ? true : false;
}
 
開發者ID:integrated,項目名稱:jakarta-slide-webdavclient,代碼行數:28,代碼來源:WebdavResource.java

示例4: uploadVCardsToWebDAV

import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private void uploadVCardsToWebDAV(String strUriFile, String strContent) {
    try {
        PutMethod httpMethod = new PutMethod(strUriFile);
        httpMethod.setRequestBody(strContent);
        this.client.executeMethod(httpMethod);
        httpMethod.releaseConnection();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
開發者ID:somedevelopment,項目名稱:CardDAVSyncOutlook,代碼行數:12,代碼來源:ManageWebDAVContacts.java

示例5: runGather

import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
/**
 * Given a queuename and broker, do an immediate gather of stats.
 * @param queueName the queue name of the service.
 * @param brokerUrl  the broker url for the service.
 * @throws IOException  if any communication exception occurs.
 */
public void runGather(final String queueName, final String brokerUrl) throws IOException {
    String requestBody = getServiceQueueExistRequestBody(queueName, brokerUrl);
    PutMethod method = new PutMethod(jamServerBaseUrl + "webservice/runGather");
    method.setRequestBody(requestBody);
    doHttpCall(method);
}
 
開發者ID:department-of-veterans-affairs,項目名稱:Leo,代碼行數:13,代碼來源:JamService.java

示例6: put

import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
private void put(String path, NameValuePair[] data) {
    PutMethod req = new PutMethod(path);
    req.setRequestBody(EncodingUtil.formUrlEncode(data, "utf-8"));
    req.getParams().setContentCharset("utf-8");
    send(req);
}
 
開發者ID:nishio-dens,項目名稱:bitbucket-pullrequest-builder-plugin,代碼行數:7,代碼來源:ApiClient.java

示例7: addServerToServiceQueue

import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
/**
 * A web service that add a server to an existing service queue.
 *
 * @param queueName the name of the queue to add this host to.
 * @param host      the host name to add to the service queue
 * @param port      the port on the host that is added to the service queue
 * @param brokerUrl  the broker url this service is using.
 * @throws IOException if any communication exception occurs.
 */
public void addServerToServiceQueue(final String queueName, final String brokerUrl,
                                    final String host, final int port) throws  IOException {
    String requestBody = createJmxServerXml(queueName, brokerUrl, host, port);
    PutMethod method = new PutMethod(jamServerBaseUrl + "webservice/addServerToServiceQueue");
    method.setRequestBody(requestBody);
    doHttpCall(method);
}
 
開發者ID:department-of-veterans-affairs,項目名稱:Leo,代碼行數:17,代碼來源:JamService.java

示例8: doesServiceQueueExist

import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
/**
 * Given a queue name, determine if it already exists.
 *
 * @param queueName the ServiceQueue.queueName to check for
 * @param brokerUrl the broker url this service is using.
 * @return returns TRUE if the service queue name exists, or false if it does not.
 * @throws IOException if any communication exception occurs.
 */
public boolean doesServiceQueueExist(final String queueName, final String brokerUrl) throws IOException {
    PutMethod method = new PutMethod(jamServerBaseUrl + "webservice/doesServiceQueueExist");

    method.setRequestBody(getServiceQueueExistRequestBody(queueName, brokerUrl));

    String result = doHttpCall(method);
    return "TRUE".equals(result);

}
 
開發者ID:department-of-veterans-affairs,項目名稱:Leo,代碼行數:18,代碼來源:JamService.java

示例9: registerServiceQueue

import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
/**
 * Registers a new service queue in Jam. Note: Service queue names MUST be unique in the jam system.
 *
 * @param queueName the name of the queue to register with.
 * @param brokerUrl the broker url this service is using.
 * @param queryIntervalInSeconds the interval in seconds to query the running service for metrics.
 * @param resetStatisticsAfterQuery if true, statistics are reset to 0 after each gather. If false, statistics are
 *                                  cumulative.
 * @param profileEnabled if true the profile is enabled for gathering, if false, it is registered, but not enabled
 *                       for gathering.
 * @throws IOException  if any communication exception occurs.
 */
public void registerServiceQueue(final String queueName, final String brokerUrl,
                                 final int queryIntervalInSeconds, final boolean resetStatisticsAfterQuery,
                                 final boolean profileEnabled) throws IOException {
    String requestBody = getRegisterServiceRequestBody(queueName, brokerUrl, queryIntervalInSeconds, resetStatisticsAfterQuery, profileEnabled);

    PutMethod method = new PutMethod(jamServerBaseUrl + "webservice/registerServiceQueue");
    method.setRequestBody(requestBody);
    doHttpCall(method);
}
 
開發者ID:department-of-veterans-affairs,項目名稱:Leo,代碼行數:22,代碼來源:JamService.java

示例10: removeServerFromServiceQueue

import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
/**
 * Remove a host/port from a service queue.
 * <p/>
 * If the host is not part of the service queue, no-op. If it is
 * part of the Service Queue, it is removed.
 * @param queueName the name of the queue to remove.
 * @param brokerUrl the broker url this service is using.
 * @param host the host the service is running on.
 * @param port the port the service is running on.
 *
 * @throws IOException if any communication exception occurs.
 */
public void removeServerFromServiceQueue(final String queueName, final String brokerUrl,
                                         final String host, final int port) throws IOException {
    String requestBody = createJmxServerXml(queueName, brokerUrl, host, port);
    PutMethod method = new PutMethod(jamServerBaseUrl + "webservice/removeServerFromServiceQueue");
    method.setRequestBody(requestBody);
    doHttpCall(method);
}
 
開發者ID:department-of-veterans-affairs,項目名稱:Leo,代碼行數:20,代碼來源:JamService.java


注:本文中的org.apache.commons.httpclient.methods.PutMethod.setRequestBody方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。