Package org.apache.commons.httpclient.methods

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


            if (log.isDebugEnabled()) {
                log.debug("Outbound SOAP message is:\n" + XMLHelper.prettyPrintXML(marshaller.marshall(message)));
            }
            XMLHelper.writeNode(marshaller.marshall(message), writer);
            return new ByteArrayRequestEntity(arrayOut.toByteArray(), "text/xml");
        } catch (MarshallingException e) {
            throw new SOAPClientException("Unable to marshall SOAP envelope", e);
        }
    }
View Full Code Here


            // are ASCII by definition but the content type may not be.  Treating the content
            // as bytes allows us to keep the current charset without worrying about how
            // this charset will effect the encoding of the form url encoded string.
            NameValuePair[] mvps = (NameValuePair[]) params.toArray(new NameValuePair[params.size()]);
            String content = EncodingUtil.formUrlEncode(mvps, getRequestCharSet());
            ByteArrayRequestEntity entity = new ByteArrayRequestEntity(
                    EncodingUtil.getAsciiBytes(content),
                    FORM_URL_ENCODED_CONTENT_TYPE
            );
            return entity;
        } else {
View Full Code Here

                        // serialized java object
                        Serializable obj = in.getMandatoryBody(Serializable.class);
                        // write object to output stream
                        ByteArrayOutputStream bos = new ByteArrayOutputStream();
                        HttpHelper.writeObjectToStream(bos, obj);
                        answer = new ByteArrayRequestEntity(bos.toByteArray(), HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT);
                        IOHelper.close(bos);
                    } else if (data instanceof File || data instanceof GenericFile) {
                        // file based (could potentially also be a FTP file etc)
                        File file = in.getBody(File.class);
                        if (file != null) {
View Full Code Here

                        // serialized java object
                        Serializable obj = in.getMandatoryBody(Serializable.class);
                        // write object to output stream
                        ByteArrayOutputStream bos = new ByteArrayOutputStream();
                        HttpHelper.writeObjectToStream(bos, obj);
                        answer = new ByteArrayRequestEntity(bos.toByteArray(), HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT);
                        IOHelper.close(bos);
                    } else if (data instanceof File || data instanceof GenericFile) {
                        // file based (could potentially also be a FTP file etc)
                        File file = in.getBody(File.class);
                        if (file != null) {
View Full Code Here

   */
  public Response put(Cluster cluster, String path, Header[] headers,
      byte[] content) throws IOException {
    PutMethod method = new PutMethod();
    try {
      method.setRequestEntity(new ByteArrayRequestEntity(content));
      int code = execute(cluster, method, headers, path);
      headers = method.getResponseHeaders();
      content = method.getResponseBody();
      return new Response(code, headers, content);
    } finally {
View Full Code Here

   */
  public Response post(Cluster cluster, String path, Header[] headers,
      byte[] content) throws IOException {
    PostMethod method = new PostMethod();
    try {
      method.setRequestEntity(new ByteArrayRequestEntity(content));
      int code = execute(cluster, method, headers, path);
      headers = method.getResponseHeaders();
      content = method.getResponseBody();
      return new Response(code, headers, content);
    } finally {
View Full Code Here

                        // serialized java object
                        Serializable obj = in.getMandatoryBody(Serializable.class);
                        // write object to output stream
                        ByteArrayOutputStream bos = new ByteArrayOutputStream();
                        HttpHelper.writeObjectToStream(bos, obj);
                        answer = new ByteArrayRequestEntity(bos.toByteArray(), HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT);
                        IOHelper.close(bos);
                    } else if (data instanceof File || data instanceof GenericFile) {
                        // file based (could potentially also be a FTP file etc)
                        File file = in.getBody(File.class);
                        if (file != null) {
View Full Code Here

   */
  protected void setRequestBody(
      HttpInvokerClientConfiguration config, PostMethod postMethod, ByteArrayOutputStream baos)
      throws IOException {

    postMethod.setRequestEntity(new ByteArrayRequestEntity(baos.toByteArray(), getContentType()));
  }
View Full Code Here

                catch( Exception e ) {
                    throw( new XPathException( this, e.getMessage() ) );
                }

                byte[] reqPayload = baos.toByteArray();
                entity = new ByteArrayRequestEntity( reqPayload, "application/xml; charset=utf-8" );
            } else {

                try {
                    entity = new StringRequestEntity( payload.getStringValue(), "text/text; charset=utf-8", "UTF-8" );
                }
View Full Code Here

              osw.flush();
              osw.close();
          } catch( Exception e ) {
            throw new XPathException(this, e);
          }
          entity = new ByteArrayRequestEntity( baos.toByteArray(), "application/xml; charset=utf-8" );

        } else if( Type.subTypeOf( payload.getType(), Type.BASE64_BINARY ) ) {

          entity = new ByteArrayRequestEntity(payload.toJavaObject(byte[].class));
         
        } else {

            try {
                entity = new StringRequestEntity( payload.getStringValue(), "text/text; charset=utf-8", "UTF-8" );
View Full Code Here

TOP

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

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.