The line of code

    resCtx = new SOAPContext(); // get rid of old one

from RPCRouterServlet, only runs when an exception is thrown.

The code that runs is something like this

RPCRouterServlet:

        provider.locate( dd, callEnv, call, call.getMethodName(), fullTargetID, 
                         reqCtx );
        ServerUtils.setResponseGzip(dd, reqCtx, resCtx);

ServerUtils:

        if (Boolean.TRUE.equals(reqCtx.getAcceptGzip())) {
          // Request specified gzip OK
          Hashtable props = dd.getProps();
          String gzip = props != null ? (String) props.get("gzip") : null;
          resCtx.setGzip(gzip != null && SoapEncUtils.decodeBooleanValue(gzip));
        } else if (Boolean.FALSE.equals(reqCtx.getAcceptGzip())) {
          // Request specified gzip not OK
          resCtx.setGzip(false);
        } else {
          // Request specified nothing, for now do not gzip
          // TODO: should accept be required?
          resCtx.setGzip(false);
        }

RPCRouterServlet:

        provider.invoke( reqCtx, resCtx );

RPCJavaProvider:

        Response resp = RPCRouter.invoke( dd, call, targetObject, 
                                          reqContext, resContext );

RPCRouter:

    return new Response (call.getTargetObjectURI (), call.getMethodName (),
                         ret, null, null, respEncStyle, resCtx);

RPCJavaProvider:

        Envelope env = resp.buildEnvelope();
        StringWriter  sw = new StringWriter(1024);
        env.marshall( sw, call.getSOAPMappingRegistry(), resContext );
        resContext.setRootPart( sw.toString(), Constants.HEADERVAL_CONTENT_TYPE_UTF8);

RPCRouterServlet:

      // Generate response.
      TransportMessage sres = new TransportMessage(null, resCtx, null );
      sres.editOutgoing(editor);

      // Generate response byte array.
      sres.save();

TransportMessage:

        if (Boolean.TRUE.equals(ctx.getGzip())) {
            // Deflate
            ByteArrayOutputStream baos =
                               new ByteArrayOutputStream(bytes.length);
            GZIPOutputStream gzos = new GZIPOutputStream(baos);
            gzos.write(bytes, offset, bytes.length - offset);
            gzos.close();
            baos.close();
            bytes = baos.toByteArray();
            offset = 0;

            headers.put(Constants.HEADER_CONTENT_ENCODING, 
Constants.HEADERVAL_CONTENT_ENCODING);
        }

RPCRouterServlet:

      // Write.
      res.setStatus(status);
      res.setContentType(sres.getContentType());
      for (Enumeration headers = sres.getHeaderNames();
           headers.hasMoreElements(); ) {
          String name = (String)headers.nextElement();
          res.setHeader(name, sres.getHeader(name));
      }

      res.setContentLength(sres.getContentLength());
      OutputStream outStream = res.getOutputStream();
      sres.writeTo(outStream);

In order to have your service gzip the result, the client must specify that it accepts 
gzip, and the deployment descriptor must have the option set to allow gzip.  Remember 
that when you change the deployment descriptor, you must re-deploy the service.

Scott Nichol

Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message ----- 
From: "Michał Małecki" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, September 13, 2004 9:32 AM
Subject: Compressing response


> Hello,
> I'm trying to compress SOAP messages (second day). The SOAP from client to
> server was archived with no problems. However, soap from server to client is
> still plain-text. I have added option "gzip", I have disabled Norton
> firewall (killed accepted-encoding header). I searched the source code
> (ws-soap_20040912104811) and I can't find out how ever the compression could
> be archived - the outputStream is gzipped if SOAPSontext.getGzip return
> true, but TransportMessage is created like this:
> new TransportMessage(null, resCtx, null );
> and resCtx is created few lines before:
> resCtx = new SOAPContext(); // get rid of old one
> so where the gzip of soapcontext could be set?
> 
> I beg you - please tell me how to archive this??
> Michał Małecki
> 
> 
>

Reply via email to