User login

Using WS-ReliableMessaging + compressing SOAP requests

Forums :

Hi,

I have installed wsas 2.2 and defined data service using sql server 2000 data source. Everything returns correctly and response from the data service looks perfect in XML.

I have some questions for you:

1. If I am engaging sandesha module does it mean that my data service I deployed supports WS-ReliableMessaging standart?

2. The total size of transferred result data is huge and in the future it will only increase. Using Data Service in WSAS 2.2 how can I compress SOAP requests to minimize traffic costs and achieve better response-request performance between client and server?

Thank you!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Answers

1. If I am engaging sandesha module does it mean that my data service I deployed supports WS-ReliableMessaging standart?

yes of course. When it come to QoS features of WSAS, it does not differentiate between a data service and any other service. Hence you can enable WS-RM,security, throttling,.... etc to a data service.

We also have a caching module (which does not get shipped with WSAS by default), using which you can cache responses for a configurable time period.

 

2. The total size of transferred result data is huge and in the future it will only increase. Using Data Service in WSAS 2.2 how can I compress SOAP requests to minimize traffic costs and achieve better response-request performance between client and server?

You can enable MTOM for data service. See the attached image on how to do this. You need to write a MTOM enabled client. Following article (http://wso2.org/library/1675) might help.

However we would like to know how many number of records (& how many columns per record)  your looking at.

/sumedha

 

AttachmentSize
mtom.jpg242.05 KB

One more question

Thank you very much for your reply.

Thus engaging sandesha module does not need any additional specific settings to set. Right?

As to MTOM I would like to clarify some details.

I am working on developing mobile application for windows mobile 5.0.

The client application is developed in Microsoft Visual C# 2005. The client requests on demand the data to be transferred in specific tables of sql server mobile edition on pda. Lets take a closer look on a specific table involved in the process of transferring data. The table consists of 5 columns, 3 of them is vacrhar 100. The total amount or rows in one request may vary from 1000 to 6000. Using data service we can easily generate XML output data and found out that the size of generated xml file is about 1.5 mg. After compressing the file by zip the size becomes 64 kb. So the main point is to compress data on server side by means of WSAS MTOM and transfer it to client with further uncompress on pda.

Enabling MTOM in WSAS what should I do in VS to engage MTOM feature? Is there any specific features in VS I have to deploy MTOM capability?

Thus engaging sandesha

Thus engaging sandesha module does not need any additional specific settings to set. Right?

no additional settings. Check the attached image.

I shall reply to other part of you question later on.

 

AttachmentSize
sandesha-engage.JPG89 KB

If you are going to consume

If you are going to consume the service only via HTTP/S, gzip encoding the response will work (if your client can handle this). Else, you should compress the XML response, say response.zip, and send it as an MTOMized attachement. The latter case will enable you to receive a compressed response via any transport.

 

Regards

Afkham Azeez

For the first case

For the fisrt case to be working I have to configure endpoint to use http port instead of currently used soap 1.2, right?

In latter case I presume, I have to perform some additional actions on data service side, so that service XML response would be at some point compressed via zip before be sent to client, correct? Given that currently my data service is configured completely wia wsas GUI, I'd like to refrain from actually writing java code on service side, unless absolutely required to do so. Is there a way to configure wsas so that it  would compress data service XML output and send it as attachment to client using means other than java code?

You can use SOAP 1.1/1.2 or

You can use SOAP 1.1/1.2 or XML over HTTP/S for the first case.

For the second option, yes, there is no direct method to do this right now without wrting custom code. If you are willing to do this, here is what I have in mind.

Write an Axis2 handler, and place it in the OutFlow. So when a message is being sent out, you can check whether it is a response from a data service.

Here is the relevant code skeleton;

public class DataServiceResponseHandler implements Handler {

public InvocationResponse invoke(MessageContext msgCtx) throws AxisFault {

        Parameter parameter = msgCtx.getServiceContext().getAxisService().getParameter(ServerConstants.SERVICE_TYPE);
        if(parameter != null && parameter.getValue().equals(DBConstants.DB_SERVICE_TYPE)){
            SOAPEnvelope response = msgCtx.getEnvelope();
          
            //TODO: If the response is larger than 1MB, save it to the file system, icompress it, and send it as an attachment

        }

}

}

Please try this out. We will include an option to compress or stream large responses in the next release of data services.

 

Regards

Afkham Azeez

Gzip option

If possible, i would prefer going gzip compression way as opposed to MTOM attachments. There is a resource I found on your site here wso2.org/library/3007. Though, I'm very new to java and not sure what code should there be around Option options = client.getOptions(); line in that sample. I mean, in terms of java programming, what kind of class should this be and how should it be deployed. Could you please clarify this for me or point ro a related working piece of code?

I currenly use WSAS data services, but looking into implementing web services proxy java classes, which would employ SOAP headers authentication, gzip compression and provide intermediary access to database, executing stored procedures and preparing data row arrays for return back to web service clients (implemented as .NET Compact applications working on Windows Mobile 5.0 platform, developed in MSVS 2005, WSAS is also deployed on Windows). I beleive, in general, employng proxy classes provides more flexibility when any kind of additional processing of database data required. If there is something you can point me on, like articles, tutorials, or samples, I would highly appreciate that.

Thank you

Sending GZIP compressed messages

Hi Sergh,

In my previous KB, I only mentioned about setting the gzip parameter in the client side. That is why you have seen client.getOptions() in http://wso2.org/library/3007.

Irrespective of where you program (whether in client side or server side), you just need to set the gzip property as a property in the context hierarchy. So the easiest method I could think of is to set that to Message context.

MessageContext messageContext = MessageContext.getCurrentMessageContext();
messageContext.setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);

Once you set this property, our http transport sender will gzip your request.

For more information on setting properties on various places, please refer http://wso2.org/library/3122.

 

POJO applicability

Hi Chinthaka,

 

Thank you for details on setting MessageContext options, this part I understand. What I dont understand, is more basic stuff, what the needed java files should look like in the first place. I found this document on POJO wso2.org/library/2893 , which clarifies for me all the basics, on how to create classes, define data types, build web services on top, what I was looking for. The question is, are POJO objects applicable for using them in conjunction with gzip technique you descripbed, or is it some other specific kind of java classes I should use?

Can I also access database from POJO objects and pass db output in form of arrays through web service?

Thank you.

The web service

The web service implementation has nothing to do with your transport details. Try putting the code I mentioned earlier inside all the methods of the POJO class and it should work.

The code I mentioned above, tries to access the message context using thread local context. It should have the current message context. IIRC, it should also work. Try it and let us know.

Eran Chinthaka

reuse data services

I tried this and everything works, tcpmon shows gzipped traffic. Thank you very much for your clarifications.

Is there a way to reuse currenlty exisiting data services from a java proxy class so that I'd add gzip compression and soap headers authentication without having to actually re-implement data supplying functionality?

Thank you

 

Hi Sergh, You want to retain

Hi Sergh,

You want to retain existing client classes & need to have a proxy class through which these client classes call existing data services.

While service call goes through this proxy class, authentication headers & compression headers get added. Did I get your question correct?

/sumedha

 

Hi sumedha,

Actually I have already implemented proxy classes so that they go to database themselves, so I do not need data services any more.

Thank you.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.