Package org.apache.commons.httpclient.methods

Examples of org.apache.commons.httpclient.methods.StringRequestEntity


        httpClient.getParams().setAuthenticationPreemptive(true);

        PostMethod postMethod = new PostMethod(uri);
        postMethod.addRequestHeader("Accept", MediaType.APPLICATION_XML.toString());

        RequestEntity entity = new StringRequestEntity(string, mediaType, "UTF-8");
        postMethod.setRequestEntity(entity);

        httpClient.executeMethod(postMethod);

        return postMethod;
View Full Code Here


        StringWriter writer = new StringWriter();
        marshaller.marshal(object, writer);

        RequestEntity entity =
            new StringRequestEntity(writer.toString(), MediaType.APPLICATION_XML.toString(), "UTF-8");
        putMethod.setRequestEntity(entity);

        httpClient.executeMethod(putMethod);

        return putMethod;
View Full Code Here

        StringWriter writer = new StringWriter();
        marshaller.marshal(object, writer);

        RequestEntity entity =
            new StringRequestEntity(writer.toString(), MediaType.APPLICATION_XML.toString(), "UTF-8");
        putMethod.setRequestEntity(entity);

        httpClient.executeMethod(putMethod);

        return putMethod;
View Full Code Here

    protected PutMethod executePut(String uri, String string, String mediaType) throws Exception
    {
        HttpClient httpClient = new HttpClient();

        PutMethod putMethod = new PutMethod(uri);
        RequestEntity entity = new StringRequestEntity(string, mediaType, "UTF-8");
        putMethod.setRequestEntity(entity);

        httpClient.executeMethod(putMethod);

        return putMethod;
View Full Code Here

        HttpClient httpClient = new HttpClient();
        httpClient.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName, password));
        httpClient.getParams().setAuthenticationPreemptive(true);

        PutMethod putMethod = new PutMethod(uri);
        RequestEntity entity = new StringRequestEntity(string, mediaType, "UTF-8");
        putMethod.setRequestEntity(entity);

        httpClient.executeMethod(putMethod);

        return putMethod;
View Full Code Here

           HttpClient client = new HttpClient();
           PostMethod method = new PostMethod(MessagingServiceMessagesURL);
           Base64 base64 = new Base64();
           String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
           method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
           method.setRequestEntity(new StringRequestEntity("Hello2 !", "text/plain", "UTF-8"));
           int status = client.executeMethod(method);
           if (HttpResponseCodes.SC_OK != status) {
               throw new RuntimeException("Messages can not be sent");
           }
       }
View Full Code Here

      HttpClient client = new HttpClient();
      PostMethod method = new PostMethod(MessagingServiceMessagesURL);
      Base64 base64 = new Base64();
      String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
      method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
      method.setRequestEntity(new StringRequestEntity("Hello !", "text/plain", "UTF-8"));
      int status = client.executeMethod(method);
      if (HttpResponseCodes.SC_OK != status) {
          throw new RuntimeException("Messages can not be sent");
      }
   }
View Full Code Here

  public JSONObject sendAndReceive(JSONObject message) {
    if (log.isDebugEnabled()) log.debug("Sending: " + message.toString(2));
    PostMethod postMethod = new PostMethod(uri.toString());
    postMethod.setRequestHeader("Content-Type", "text/plain");
   
    RequestEntity requestEntity= new StringRequestEntity(message.toString());
    postMethod.setRequestEntity(requestEntity);
    try {
      http().executeMethod(null, postMethod, state);
      int statusCode= postMethod.getStatusCode();
      if (statusCode!=HttpStatus. SC_OK)
View Full Code Here

      }else{
        logInfo("Authorization: NONE",null);
      }
      method.setRequestHeader("Content-Type", "application/xml; charset=utf-8");     
      try {
        method.setRequestEntity(new StringRequestEntity(registrationData, "application/xml", "UTF8"));
        client.executeMethod(method);
        int status = method.getStatusCode();
        if (status == HttpStatus.SC_NOT_MODIFIED || status == HttpStatus.SC_OK) {
          logInfo("Successfully registered OLAT installation on olat.org server, thank you for your support!", null);
          registrationKey = method.getResponseBodyAsString();
View Full Code Here

                PostMethod post = new PostMethod(url);
                String content = SOSFile.readFile(inputFile);
                getLogger().debug9("post before replacements: "+content);
                content = mergedVariables.substitute(content);
                getLogger().debug5("Posting: "+content);
                StringRequestEntity req = new StringRequestEntity(content);
                // post.setRequestEntity(new InputStreamRequestEntity(new FileInputStream(inputFile), inputFile.length()));
                post.setRequestEntity(req);
                post.setRequestHeader("Content-type", contentType);

                HttpClient httpClient = new HttpClient();
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.methods.StringRequestEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.