Hi,
I have made changes to your client and server code so that Huge data
can be sent in Attachments instead of SOAP Body. This works very fast
if you can disable all the System.out calls to make it even better.
Also you can refine the server side code to read the exact attachment
contents ( i just did some quick and dirty thing just to demonstrate).
Attached are the client and server jars/wars. Let us know if you were
able to run it.
Thanks.
V B Kumar Jayanti wrote:
> Hi,
>
> Thanks for the TestCase. I had to do some modifications in the
> code and actually it never hangs but yes it takes a lot of time. It
> took me 10 mins on my Windows Laptop.
>
> Changes made :
> 1. please do not do message.writeTo(System.out) for such huge
> messages. There is an issue in SAAJ (RFE filed) w.r.t this in the
> sense that this method tries to write the entire stream into an
> internal buffer. So i commented all un-necessary writeTo calls on
> both the client and server side
> 2. Also i saw body.toString() to create the response, i just
> changed that as well.
> 3. Also instead of keeping the SAAJ jars inside the WAR file
> WEB-INF/lib directory i installed the jars in tomcat by copying them
> to <TOMCAT_HOME>/shared/lib
>
> After these changes it runs fine, here are my client and server
> outputs (attached are the modified server and client WAR and JAR files)
>
> -------------------Client Ouput------------------
> E:\SAAJTESt>java -classpath
> .;activation.jar;webservices-api.jar;webservices-rt.
> jar br.gov.se.sefaz.nfe.geracaoXML.TestCaseClient
> http://localhost:8080/testcase
> server/TestCase
> Got Response=
> <env:Envelope
> xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Body><tes
> tecaseResponse
> xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/testcase"><testeca
> seResult>this is a
> response</testecaseResult></testecaseResponse></env:Body></en
> v:Envelope>
> E:\SAAJTESt>
> ----------------------Client Output-----------------------
>
> ---------------Server Output------------------------------
> .Sep 27, 2007 4:06:19 PM org.apache.catalina.startup.HostConfig deployWAR
> INFO: Deploying web application archive testcaseserver.war
> .....Inside ON MESSSAGE
> Time Taken=542 seconds
> DONE WITH getSOAPBODY()
> , First Child=
> {http://www.portalfiscal.inf.br/nfe/wsdl/NfeRecepcao}nfeRecepcaoL
> ote
> ----------------Server Output------------------------------
>
> but yes, it is taking about 9 to 10 mins to complete on my laptop.
>
> Now you should really consider using other mechanism when the content
> of the SOAPBody is Huge.
>
> 1. Consider making it a Text Attachment unless you really need the
> contents to be treated as XML you need not send them in Body.
> 2. If the contents of SOAPBody is Binary Data then instead of base64
> encoding it you can use JAXWS with MTOM enabled. This will ensure that
> the Binary data is transferred as an Attachment instead (allowing
> faster message transfer)
> 3. Consider migrating this whole step to JAXWS WebService as opposed
> to SAAJ Servlet.
>
> We have tested attachments upto 20 MB in the past and it works, i will
> try and send a modified program of yours using attachments in my next
> email.
>
> Thanks.
>
> Luiz Ricardo wrote:
>
>> Hi,
>>
>> thanks for the answer! We are using SAAJ 1.3 (SOAP 1.2) + Tomcat
>> 6.0.10 + JDK 1.5.0. We are sending to you the "Reproducable Testcase"
>> where the client sends a request with nearly 400 kb and the server
>> will hang when the getSOAPBody() is invoked.
>>
>> To execute the client use the following command:
>>
>> java -jar testcaseclient.jar http://localhost/testcase/TestCase
>>
>> Regards,
>>
>> Luiz Ricardo Belém Santos and NF-e Team
>> Sun Certified Programmer for the Java 2 Platform
>>
>>
>> ----- Mensagem original ----
>> De: V B Kumar Jayanti <Vbkumar.Jayanti_at_Sun.COM>
>> Para: users_at_saaj.dev.java.net
>> Enviadas: Quarta-feira, 26 de Setembro de 2007 4:02:54
>> Assunto: Re: [SAAJ-USR] Problems with getSOAPBody from SAAJ
>>
>> Hi,
>> Which version of SAAJ are you using. Why not try using JAXWS for
>> doing this kind of things. I also see that you are doing some kind of
>> SOAP Message security, for that you can make use of WSIT.
>>
>> If you think the problem is occuring with the latest version of
>> SAAJ then can you send us a Reproducable Testcase that i can run.
>>
>> Thanks.
>>
>> Luiz Ricardo wrote:
>>
>>> Hi everyone,
>>>
>>> I'm from Aracaju - SE, Brazil. I'm with problems invoking
>>> the getSOAPBody() method. It was developed a web service using the
>>> SAAJ API and subclassing SAAJServlet and now when a client sends a
>>> request with length nearly 400 kb my servlets hangs just at this
>>> point, that is, invoking the getSOAPBody() method.
>>>
>>> Follow below the piece of code:
>>>
>>> ...
>>> @Override
>>> public SOAPMessage onMessage(SOAPMessage message,
>>> HttpServletRequest request) {
>>> try {
>>> String response = null;
>>> // it hangs here!!!! :(((
>>> *SOAPBody body = message.getSOAPBody();
>>> * // recupera a URI do namespace do serviço
>>> String namespaceUri = getNamespaceUri();
>>> // recupera o conteúdo XML da área de cabeçalho da mensagem
>>> String nfeCabecMsg = body.getElementsByTagNameNS(namespaceUri,
>>> "nfeCabecMsg").item(0).getTextContent();
>>> // recupera o conteúdo XML da área de dados da mensagem
>>> String nfeDadosMsg = body.getElementsByTagNameNS(namespaceUri,
>>> "nfeDadosMsg").item(0).getTextContent();
>>> // recupera o nome do método do web service que está sendo
>>> invocado pelo cliente
>>> String metodo = body.getFirstChild().getNodeName();
>>> // testa se o nome do método invocado coincide com o nome do
>>> serviço
>>> if (!metodo.equals(getNomeMetodoServico())) {
>>> String msg = "Chamada ao método " + metodo + " quando o
>>> esperado era " + getNomeMetodoServico() + ".";
>>> logger.error(msg);
>>> throw new IllegalArgumentException(msg);
>>> }
>>>
>>> X509Certificate[] cert = (X509Certificate[])
>>> request.getAttribute("javax.servlet.request.X509Certificate");
>>>
>>> TORequisicaoCliente rc = new TORequisicaoCliente();
>>> rc.setXmlCabec(nfeCabecMsg);
>>> rc.setXmlDados(nfeDadosMsg);
>>> rc.setX509Cert(cert[0]);
>>> response = validacaoInicial(rc,
>>> WS_NFE_RECEPCAO.equals(getServletName()));
>>> return montarMensagemSOAP(response);
>>> } catch (DOMException dome) {
>>> logger.error("Erro ao tentar recuperar partes do corpo da
>>> mensagem SOAP.", dome);
>>> } catch (SOAPException soape) {
>>> logger.error("Erro ao tentar recuperar/criar mensagem SOAP.",
>>> soape);
>>> } catch (Exception e) {
>>> logger.error("Erro inesperado.", e);
>>> }
>>> return null;
>>> }
>>> ...
>>>
>>> Please, help us! Me and my team are waiting to resolve this problem!
>>> Any help is welcome!
>>>
>>> Regards,
>>>
>>> Luiz Ricardo Belém Santos
>>> Sun Certified Programmer for the Java 2 Platform
>>>
>>> Flickr agora em português. Você clica, todo mundo vê. Saiba mais
>>> <http://br.rd.yahoo.com/mail/taglines/flickr/*http://www.flickr.com.br/>.
>>
>>
>>
>>
>>
>> Flickr agora em português. Você clica, todo mundo vê. Saiba mais
>> <http://br.rd.yahoo.com/mail/taglines/flickr/*http://www.flickr.com.br/>.
>>
>>
>>------------------------------------------------------------------------
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe_at_saaj.dev.java.net
>>For additional commands, e-mail: users-help_at_saaj.dev.java.net
>>
>>
>