You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by jim ma <ma...@gmail.com> on 2006/12/12 04:55:12 UTC

Re: Why it only read 28 bytes

Can anyone shed some light on this ?

On 12/8/06, jim ma <ma...@gmail.com> wrote:
>
> Hi all ,
>
> I think this is a bug maybe introduced by jakarta-httpcore-4.0-alpha2.
> When enable the chunk mode for StringEntity , client will read 28 bytes each
> time . Client will read many times when a large payload response returned .
> This definitely affects Aixs2's performance.
>
> Axis2 need to set chunk buffersize for HttpCore before invoking
> StringEntity.setChunk(true) ?
>
> Regards
>
> Jim
>
> On 12/5/06, jim ma <ma...@gmail.com> wrote:
> >
> > Hi all ,
> >
> > I downloaded the aixs2 1.1 std kit and tried a simple sample contains
> > one operation: echoString() . After I deployed the service in repository and
> > launch the server with axis2server.I wrote the following code to send
> > the payload to aixs2server and soap response :
> >
> > httpCon.getOutputStream().write(payload);
> > httpCon.getOutputStream().flush();
> > byte[] buffer = new byte[1024];
> > count = httpCon.getInputStream().read(buffer);
> > while (count > 0) {
> >        System.out.println ("---readed----" + count);
> >        count = httpCon.getInputStream().read(buffer);
> > }
> >
> > I found the thing confused me : each time it only can read 28 bytes from
> > inputStream . Large size respsone will be readed many times.  But I deployed
> > it into tomcat , It will read 1024 bytes each time.
> >
> > Which line code in Artix2 1.1 cause this ?
> >
> > Thanks
> >
> > Jim
> >
> >
> >
> >
> >
>
>

Re: Why it only read 28 bytes

Posted by jim ma <ma...@gmail.com>.
Hi Oleg,

It's  JDK's issue .  I will modify my code to use Commons HttpClient.

Thanks

Jim



On 12/13/06, Oleg Kalnichevski <ol...@apache.org> wrote:
>
> On Wed, 2006-12-13 at 16:31 +0800, jim ma wrote:
> > Oleg,
> >
> > Thank you for your quick reply.
> >
> > You can use following steps to reproduce this issue:
>
> ...
>
> >  When I set the buffer size is 1024*1 ,  readed count will be :
> > ---count -----32
> > ---count -----1024
> > ---count -----638
> >
> > buffersize is 1024*2 , The output is :
> > ---count -----27
> > ---count -----1667
> >
> > buffersize is 1024*3 ,output will be :
> > ---count -----32
> > ---count -----1662
> >
> >  Regards
> >
> > Jim
> >
>
> Hi Jim,
>
> The problem is perfectly reproducible. However, at this point I do not
> see any evidence of this being a problem with HttpCore.
>
> When submitting an identical request using Commons HttpClient instead of
> HttpUrlConnection this is what I get:
>
> ---count -----1694
>
> [DEBUG] header - >> "POST /axis2/services/Axis2SampleDocLitService
> HTTP/1.1[\r][\n]"
> [DEBUG] header - >> "User-Agent: Jakarta
> Commons-HttpClient/3.1-beta1[\r][\n]"
> [DEBUG] header - >> "Host: localhost:8080[\r][\n]"
> [DEBUG] header - >> "Content-Length: 1676[\r][\n]"
> [DEBUG] header - >> "Content-Type: text/xml; charset=UTF-8[\r][\n]"
> [DEBUG] header - >> "[\r][\n]"
> [DEBUG] content - >> "<?xml version='1.0'
> encoding='UTF-8'?><soapenv:Envelope
> ...
> [DEBUG] header - << "HTTP/1.1 200 OK[\r][\n]"
> [DEBUG] header - << "Date: Wed, 13 Dec 2006 13:20:35 GMT[\r][\n]"
> [DEBUG] header - << "Server: Simple-Server/1.1[\r][\n]"
> [DEBUG] header - << "Transfer-Encoding: chunked[\r][\n]"
> [DEBUG] header - << "Content-Type: text/xml; charset=UTF-8[\r][\n]"
> [DEBUG] content - << "6"
> [DEBUG] content - << "9"
> [DEBUG] content - << "e"
> [DEBUG] content - << "[\r]"
> [DEBUG] content - << "[\n]"
> [DEBUG] content - << "<?xml version='1.0'
> encoding='UTF-8'?><soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header
> /><soapenv:Body><echoStringResponse xmlns="
> http://userguide.axis2.apache.org/Axis2SampleDocLit"><echoStringReturn
> ...
> [DEBUG] content - << "[\r]"
> [DEBUG] content - << "[\n]"
> [DEBUG] content - << "0"
> [DEBUG] content - << "[\r]"
> [DEBUG] content - << "[\n]"
> [DEBUG] content - << "[\r]"
> [DEBUG] content - << "[\n]"
>
> As you you can see from the wire log HttpCore correctly generates only
> one chunk of content and HttpClient reads it as one chunk. I am not of a
> very high opinion about HttpURLConnection in general and in this
> particular instance tend to think this problem is likely to be
> HttpURLConnection's fault.
>
> Is there anything I may be missing?
>
> Oleg
> ----
>
> test code
> ===============
> HttpClient httpclient = new HttpClient();
>
> byte[] buffer = new byte[1024*5];
>
> String outstr = "<?xml version='1.0' encoding='UTF-8'?>"
>     + "<soapenv:Envelope xmlns:soapenv=
> \"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header
> /><soapenv:Body><echoString xmlns=\"
> http://userguide.axis2.apache.org/Axis2SampleDocLit\"><echoStringParam
> xmlns=\"http://userguide.axis2.apache.org/xsd\
> ">ECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRING</echoStringParam></echoString></soapenv:Body></soapenv:Envelope>";
>
> PostMethod httppost = new
> PostMethod("http://localhost:8080/axis2/services/Axis2SampleDocLitService
> ");
> RequestEntity requestEntity = new StringRequestEntity(outstr,
> "text/xml", "UTF-8");
> httppost.setRequestEntity(requestEntity);
> try {
>     httpclient.executeMethod(httppost);
>
>     ByteArrayOutputStream out = new ByteArrayOutputStream();
>     InputStream in = httppost.getResponseBodyAsStream();
>     int count;
>     while ((count = in.read(buffer)) > 0) {
>         System.out.println("---count -----" + count);
>         out.write(buffer, 0, count);
>     }
> } finally {
>     httppost.releaseConnection();
> }
> ==============
>
>
> >
> >
> > On 12/12/06, Oleg Kalnichevski <ol...@apache.org> wrote:
> >         On Tue, 2006-12-12 at 11:55 +0800, jim ma wrote:
> >         >
> >         > Can anyone shed some light on this ?
> >         >
> >
> >         Jim,
> >
> >         HttpCore uses 2048 byte chunks per default and as far as I
> >         know Axis2
> >         SimpleHttpServer does not override this default behavior.
> >
> >
> http://jakarta.apache.org/httpcomponents/httpcore/jakarta-httpcore/xref/org/apache/http/io/ChunkedOutputStream.html#132
> >
> >         I simply do not see a way for HttpCore to produce content
> >         chunks less
> >         then 2048.
> >
> >         Please give me a little more details how to reproduce the
> >         problem
> >         locally.
> >
> >         Oleg
> >
> >
> >         > On 12/8/06, jim ma < mail2jimma@gmail.com> wrote:
> >         >         Hi all ,
> >         >
> >         >         I think this is a bug maybe introduced by
> >         >         jakarta-httpcore-4.0-alpha2.  When enable the chunk
> >         mode for
> >         >         StringEntity , client will read 28 bytes each time .
> >         Client
> >         >         will read many times when a large payload response
> >         returned .
> >         >         This definitely affects Aixs2's performance.
> >         >
> >         >         Axis2 need to set chunk buffersize for HttpCore
> >         before
> >         >         invoking StringEntity.setChunk(true) ?
> >         >
> >         >         Regards
> >         >
> >         >         Jim
> >         >
> >         >
> >         >         On 12/5/06, jim ma < mail2jimma@gmail.com> wrote:
> >         >                 Hi all ,
> >         >
> >         >                 I downloaded the aixs2 1.1 std kit and tried
> >         a simple
> >         >                 sample contains one operation:
> >         echoString() . After I
> >         >                 deployed the service in repository and
> >         launch the
> >         >                 server with axis2server.I wrote the
> >         following code to
> >         >                 send the payload to aixs2server and soap
> >         response :
> >         >
> >         >                 httpCon.getOutputStream().write(payload);
> >         >                 httpCon.getOutputStream().flush();
> >         >                 byte[] buffer = new byte[1024];
> >         >                 count =
> >         httpCon.getInputStream().read(buffer);
> >         >                 while (count > 0) {
> >         >                        System.out.println ("---readed----" +
> >         count);
> >         >                        count = httpCon.getInputStream
> >         ().read(buffer);
> >         >                 }
> >         >
> >         >                 I found the thing confused me : each time it
> >         only can
> >         >                 read 28 bytes from inputStream . Large size
> >         respsone
> >         >                 will be readed many times.  But I deployed
> >         it into
> >         >                 tomcat , It will read 1024 bytes each time.
> >         >
> >         >                 Which line code in Artix2 1.1 cause this ?
> >         >
> >         >                 Thanks
> >         >
> >         >                 Jim
> >         >
> >         >
> >         >
> >         >
> >         >
> >         >
> >         >
> >
> >
> >
> ---------------------------------------------------------------------
> >         To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> >         For additional commands, e-mail: axis-dev-help@ws.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>

Re: Why it only read 28 bytes

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2006-12-13 at 16:31 +0800, jim ma wrote:
> Oleg,
> 
> Thank you for your quick reply.
> 
> You can use following steps to reproduce this issue:

...

>  When I set the buffer size is 1024*1 ,  readed count will be : 
> ---count -----32
> ---count -----1024
> ---count -----638
> 
> buffersize is 1024*2 , The output is :
> ---count -----27
> ---count -----1667
> 
> buffersize is 1024*3 ,output will be :
> ---count -----32
> ---count -----1662
> 
>  Regards
> 
> Jim
> 

Hi Jim,

The problem is perfectly reproducible. However, at this point I do not
see any evidence of this being a problem with HttpCore. 

When submitting an identical request using Commons HttpClient instead of
HttpUrlConnection this is what I get:

---count -----1694

[DEBUG] header - >> "POST /axis2/services/Axis2SampleDocLitService
HTTP/1.1[\r][\n]"
[DEBUG] header - >> "User-Agent: Jakarta
Commons-HttpClient/3.1-beta1[\r][\n]"
[DEBUG] header - >> "Host: localhost:8080[\r][\n]"
[DEBUG] header - >> "Content-Length: 1676[\r][\n]"
[DEBUG] header - >> "Content-Type: text/xml; charset=UTF-8[\r][\n]"
[DEBUG] header - >> "[\r][\n]"
[DEBUG] content - >> "<?xml version='1.0'
encoding='UTF-8'?><soapenv:Envelope 
...
[DEBUG] header - << "HTTP/1.1 200 OK[\r][\n]"
[DEBUG] header - << "Date: Wed, 13 Dec 2006 13:20:35 GMT[\r][\n]"
[DEBUG] header - << "Server: Simple-Server/1.1[\r][\n]"
[DEBUG] header - << "Transfer-Encoding: chunked[\r][\n]"
[DEBUG] header - << "Content-Type: text/xml; charset=UTF-8[\r][\n]"
[DEBUG] content - << "6"
[DEBUG] content - << "9"
[DEBUG] content - << "e"
[DEBUG] content - << "[\r]"
[DEBUG] content - << "[\n]"
[DEBUG] content - << "<?xml version='1.0'
encoding='UTF-8'?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header /><soapenv:Body><echoStringResponse xmlns="http://userguide.axis2.apache.org/Axis2SampleDocLit"><echoStringReturn 
...
[DEBUG] content - << "[\r]"
[DEBUG] content - << "[\n]"
[DEBUG] content - << "0"
[DEBUG] content - << "[\r]"
[DEBUG] content - << "[\n]"
[DEBUG] content - << "[\r]"
[DEBUG] content - << "[\n]"

As you you can see from the wire log HttpCore correctly generates only
one chunk of content and HttpClient reads it as one chunk. I am not of a
very high opinion about HttpURLConnection in general and in this
particular instance tend to think this problem is likely to be
HttpURLConnection's fault.

Is there anything I may be missing?

Oleg
----

test code
===============
HttpClient httpclient = new HttpClient();

byte[] buffer = new byte[1024*5];

String outstr = "<?xml version='1.0' encoding='UTF-8'?>"
    + "<soapenv:Envelope xmlns:soapenv=
\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header /><soapenv:Body><echoString xmlns=\"http://userguide.axis2.apache.org/Axis2SampleDocLit\"><echoStringParam xmlns=\"http://userguide.axis2.apache.org/xsd\">ECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRING</echoStringParam></echoString></soapenv:Body></soapenv:Envelope>"; 

PostMethod httppost = new
PostMethod("http://localhost:8080/axis2/services/Axis2SampleDocLitService");
RequestEntity requestEntity = new StringRequestEntity(outstr,
"text/xml", "UTF-8");
httppost.setRequestEntity(requestEntity);
try {
    httpclient.executeMethod(httppost);
    
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    InputStream in = httppost.getResponseBodyAsStream();
    int count;
    while ((count = in.read(buffer)) > 0) {
        System.out.println("---count -----" + count);
        out.write(buffer, 0, count);
    }
} finally {
    httppost.releaseConnection();
}
==============


> 
> 
> On 12/12/06, Oleg Kalnichevski <ol...@apache.org> wrote:
>         On Tue, 2006-12-12 at 11:55 +0800, jim ma wrote:
>         >
>         > Can anyone shed some light on this ?
>         >
>         
>         Jim,
>         
>         HttpCore uses 2048 byte chunks per default and as far as I
>         know Axis2
>         SimpleHttpServer does not override this default behavior. 
>         
>         http://jakarta.apache.org/httpcomponents/httpcore/jakarta-httpcore/xref/org/apache/http/io/ChunkedOutputStream.html#132
>         
>         I simply do not see a way for HttpCore to produce content
>         chunks less
>         then 2048.
>         
>         Please give me a little more details how to reproduce the
>         problem
>         locally.
>         
>         Oleg
>         
>         
>         > On 12/8/06, jim ma < mail2jimma@gmail.com> wrote:
>         >         Hi all ,
>         >
>         >         I think this is a bug maybe introduced by 
>         >         jakarta-httpcore-4.0-alpha2.  When enable the chunk
>         mode for 
>         >         StringEntity , client will read 28 bytes each time .
>         Client
>         >         will read many times when a large payload response
>         returned .
>         >         This definitely affects Aixs2's performance.
>         > 
>         >         Axis2 need to set chunk buffersize for HttpCore
>         before
>         >         invoking StringEntity.setChunk(true) ?
>         >
>         >         Regards
>         >
>         >         Jim
>         >
>         >
>         >         On 12/5/06, jim ma < mail2jimma@gmail.com> wrote:
>         >                 Hi all ,
>         >
>         >                 I downloaded the aixs2 1.1 std kit and tried
>         a simple
>         >                 sample contains one operation:
>         echoString() . After I 
>         >                 deployed the service in repository and
>         launch the
>         >                 server with axis2server.I wrote the
>         following code to
>         >                 send the payload to aixs2server and soap
>         response : 
>         >
>         >                 httpCon.getOutputStream().write(payload);
>         >                 httpCon.getOutputStream().flush();
>         >                 byte[] buffer = new byte[1024];
>         >                 count =
>         httpCon.getInputStream().read(buffer);
>         >                 while (count > 0) {
>         >                        System.out.println ("---readed----" +
>         count);
>         >                        count = httpCon.getInputStream
>         ().read(buffer);
>         >                 }
>         >
>         >                 I found the thing confused me : each time it
>         only can
>         >                 read 28 bytes from inputStream . Large size
>         respsone
>         >                 will be readed many times.  But I deployed
>         it into 
>         >                 tomcat , It will read 1024 bytes each time.
>         >
>         >                 Which line code in Artix2 1.1 cause this ?
>         >
>         >                 Thanks
>         >
>         >                 Jim
>         >
>         >
>         >
>         >
>         >
>         >
>         >
>         
>         
>         ---------------------------------------------------------------------
>         To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
>         For additional commands, e-mail: axis-dev-help@ws.apache.org
>         
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: Why it only read 28 bytes

Posted by jim ma <ma...@gmail.com>.
Oleg,

Thank you for your quick reply.

You can use following steps to reproduce this issue:

(1) Use " wsdl2java -ss -sd -ssi -d xmlbeans -uri  Axis2SampleDocLit.wsdl "
on windows Xp platform to generate java code .

<<Axis2SampleDocLit.wsdl>>

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="Axis2SampleDocLitService"
    targetNamespace="http://userguide.axis2.apache.org/Axis2SampleDocLit"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="http://userguide.axis2.apache.org/Axis2SampleDocLit"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsd1="http://userguide.axis2.apache.org/xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <types>
        <schema targetNamespace="http://userguide.axis2.apache.org/xsd"
            xmlns="http://www.w3.org/2001/XMLSchema"
            xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
            elementFormDefault="qualified">

            <element name="echoStringParam" type="xsd:string"/>

            <element name="echoStringReturn" type="xsd:string"/>

        </schema>
    </types>
    <message name="echoString">
        <part element="xsd1:echoStringParam" name="a"/>
    </message>
    <message name="echoStringResponse">
        <part element="xsd1:echoStringReturn" name="result"/>
    </message>

    <portType name="Axis2SampleDocLitPortType">
        <operation name="echoString">
            <input message="tns:echoString" name="echoString"/>
            <output message="tns:echoStringResponse"
name="echoStringResponse"/>
        </operation>

    </portType>
    <binding name="Axis2SampleDocLitPortBinding"
        type="tns:Axis2SampleDocLitPortType">
        <soap:binding style="document" transport="
http://schemas.xmlsoap.org/soap/http"/>
        <operation name="echoString">
            <soap:operation soapAction="echoString" style="rpc"/>
            <input name="echoString">
                <soap:body namespace="
http://userguide.axis2.apache.org/Axis2SampleDocLit"
                    use="literal"/>
            </input>
            <output name="echoStringResponse">
                <soap:body namespace="
http://userguide.axis2.apache.org/Axis2SampleDocLit"
                    use="literal"/>
            </output>
        </operation>
    </binding>
    <service name="Axis2SampleDocLitService">
        <port binding="tns:Axis2SampleDocLitPortBinding"
            name="Axis2SampleDocLitPort">
            <soap:address
                location="
http://userguide.axis2.apache.org/stkv3/wsdl/Axis2SampleDocLit.wsdl"/>
        </port>
    </service>
</definitions>

(2) Added the implemententation to  class Axis2SampleDocLitServiceSkeleton:
     public EchoStringResponseDocument echoString(EchoStringDocument param2)
{
        EchoStringResponseDocument resDoc =
EchoStringResponseDocument.Factory.newInstance();
        EchoStringResponseDocument.EchoStringResponse response =
resDoc.addNewEchoStringResponse();
        response.setEchoStringReturn(param2.getEchoString
().getEchoStringParam());
        return resDoc;
     }

(3)  Packag  deploy  this service to Axis2 repository .

(4) Run the following simple client to send the soap request and receive the
response from axis2 standalone server
        byte[] buffer = new byte[1024*5];
        URL url;
        try {
            url = new URL("
http://localhost:8080/axis2/services/Axis2SampleDocLitService");

            HttpURLConnection urlCon =
(HttpURLConnection)url.openConnection();
            urlCon.setDoOutput(true);
            urlCon.setRequestMethod("POST");
            urlCon.setUseCaches(false);
            urlCon.setRequestProperty("Content-Type", "text/xml");
            String outstr = "<?xml version='1.0' encoding='UTF-8'?>"
                            + "<soapenv:Envelope xmlns:soapenv=\"
http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header
/><soapenv:Body><echoString xmlns=\"
http://userguide.axis2.apache.org/Axis2SampleDocLit\"><echoStringParam
xmlns=\"http://userguide.axis2.apache.org/xsd\
">ECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRINGECHOSTRING</echoStringParam></echoString></soapenv:Body></soapenv:Envelope>";
            urlCon.getOutputStream().write(outstr.getBytes());
            urlCon.getOutputStream().flush();
            int count = 0;
            if (urlCon.getResponseCode() !=
java.net.HttpURLConnection.HTTP_OK) {
                System.err.println
("--------------ERROR---------------------------");
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                count = urlCon.getInputStream().read(buffer);
                while (count > 0) {
                    out.write(buffer, 0, count);
                    count = urlCon.getInputStream().read(buffer);
                }
                System.err.println(out.toString());
                System.err.println
("--------------ERROR---------------------------");
                throw new java.lang.RuntimeException("Reponse err: server
reponse code is "
                                                     +
urlCon.getResponseCode());
            }

            ByteArrayOutputStream out = new ByteArrayOutputStream();
            count = urlCon.getInputStream().read(buffer);
            while (count > 0) {
                System.out.println("---count -----" + count);
                out.write(buffer, 0, count);
                count = urlCon.getInputStream().read(buffer);
            }

            if (out.toString().toLowerCase().indexOf("fail") > -1) {
                throw new RuntimeException("Response err: soap err message
is returned");
            }

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

 When I set the buffer size is 1024*1 ,  readed count will be :
---count -----32
---count -----1024
---count -----638

buffersize is 1024*2 , The output is :
---count -----27
---count -----1667

buffersize is 1024*3 ,output will be :
---count -----32
---count -----1662

 Regards

Jim



On 12/12/06, Oleg Kalnichevski <ol...@apache.org> wrote:
>
> On Tue, 2006-12-12 at 11:55 +0800, jim ma wrote:
> >
> > Can anyone shed some light on this ?
> >
>
> Jim,
>
> HttpCore uses 2048 byte chunks per default and as far as I know Axis2
> SimpleHttpServer does not override this default behavior.
>
> http://jakarta.apache.org/httpcomponents/httpcore/jakarta-httpcore/xref/org/apache/http/io/ChunkedOutputStream.html#132
>
>
> I simply do not see a way for HttpCore to produce content chunks less
> then 2048.
>
> Please give me a little more details how to reproduce the problem
> locally.
>
> Oleg
>
>
> > On 12/8/06, jim ma < mail2jimma@gmail.com> wrote:
> >         Hi all ,
> >
> >         I think this is a bug maybe introduced by
> >         jakarta-httpcore-4.0-alpha2.  When enable the chunk mode for
> >         StringEntity , client will read 28 bytes each time . Client
> >         will read many times when a large payload response returned .
> >         This definitely affects Aixs2's performance.
> >
> >         Axis2 need to set chunk buffersize for HttpCore before
> >         invoking StringEntity.setChunk(true) ?
> >
> >         Regards
> >
> >         Jim
> >
> >
> >         On 12/5/06, jim ma < mail2jimma@gmail.com> wrote:
> >                 Hi all ,
> >
> >                 I downloaded the aixs2 1.1 std kit and tried a simple
> >                 sample contains one operation: echoString() . After I
> >                 deployed the service in repository and launch the
> >                 server with axis2server.I wrote the following code to
> >                 send the payload to aixs2server and soap response :
> >
> >                 httpCon.getOutputStream().write(payload);
> >                 httpCon.getOutputStream().flush();
> >                 byte[] buffer = new byte[1024];
> >                 count = httpCon.getInputStream().read(buffer);
> >                 while (count > 0) {
> >                        System.out.println ("---readed----" + count);
> >                        count = httpCon.getInputStream ().read(buffer);
> >                 }
> >
> >                 I found the thing confused me : each time it only can
> >                 read 28 bytes from inputStream . Large size respsone
> >                 will be readed many times.  But I deployed it into
> >                 tomcat , It will read 1024 bytes each time.
> >
> >                 Which line code in Artix2 1.1 cause this ?
> >
> >                 Thanks
> >
> >                 Jim
> >
> >
> >
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>

Re: Why it only read 28 bytes

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2006-12-12 at 11:55 +0800, jim ma wrote:
> 
> Can anyone shed some light on this ?
> 

Jim,

HttpCore uses 2048 byte chunks per default and as far as I know Axis2
SimpleHttpServer does not override this default behavior. 

http://jakarta.apache.org/httpcomponents/httpcore/jakarta-httpcore/xref/org/apache/http/io/ChunkedOutputStream.html#132

I simply do not see a way for HttpCore to produce content chunks less
then 2048. 

Please give me a little more details how to reproduce the problem
locally.

Oleg


> On 12/8/06, jim ma <ma...@gmail.com> wrote:
>         Hi all ,
>         
>         I think this is a bug maybe introduced by
>         jakarta-httpcore-4.0-alpha2.  When enable the chunk mode for
>         StringEntity , client will read 28 bytes each time . Client
>         will read many times when a large payload response returned .
>         This definitely affects Aixs2's performance.  
>         
>         Axis2 need to set chunk buffersize for HttpCore before
>         invoking StringEntity.setChunk(true) ? 
>         
>         Regards
>         
>         Jim
>         
>         
>         On 12/5/06, jim ma <ma...@gmail.com> wrote:
>                 Hi all , 
>                 
>                 I downloaded the aixs2 1.1 std kit and tried a simple
>                 sample contains one operation: echoString() . After I
>                 deployed the service in repository and launch the
>                 server with axis2server.I wrote the following code to
>                 send the payload to aixs2server and soap response : 
>                 
>                 httpCon.getOutputStream().write(payload);
>                 httpCon.getOutputStream().flush();
>                 byte[] buffer = new byte[1024];
>                 count = httpCon.getInputStream().read(buffer);
>                 while (count > 0) {
>                        System.out.println ("---readed----" + count);
>                        count = httpCon.getInputStream().read(buffer);
>                 }
>                 
>                 I found the thing confused me : each time it only can
>                 read 28 bytes from inputStream . Large size respsone
>                 will be readed many times.  But I deployed it into
>                 tomcat , It will read 1024 bytes each time. 
>                 
>                 Which line code in Artix2 1.1 cause this ? 
>                 
>                 Thanks 
>                 
>                 Jim
>                 
>                 
>                 
>                   
>         
>         
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org