views:

17

answers:

1

I've been trying to enable fastinfoset compression on my web services. However, I'm having a problem getting the content-type to change on the request from the client. At least, I think that's why it's not compressing.

I've tried a lot of different things, but the content-type always remains "text/xml". I'm pretty sure that it's supposed go through as "application/soap+fastinfoset" the way I have it set up now. I'm running Axis2 as a standalone, but again I think the problem is that the content type header isn't changing.

I know the options themselves are getting set on the request because I was able to change another option from "UTF-8" to "UTF-16", and it showed up in the header. Here's the current header output from TCPMonitor:

POST /axis2/services/AddressBookService HTTP/1.1

Content-Type: text/xml; charset=UTF-16

SOAPAction: "urn:anonRobustOp"

User-Agent: Axis2

Host: 127.0.0.1:1237

Transfer-Encoding: chunked

The client code is shown below. Any help much appreciated.

package sample.addressbook.rpcclient;



import javax.xml.namespace.QName;    
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
import org.apache.axis2.Constants; 
import sample.addressbook.entry.Entry;


public class AddressBookRPCClient {

    public static void main(String[] args1) throws AxisFault {

        RPCServiceClient serviceClient = new RPCServiceClient();

        Options options = serviceClient.getOptions();

        options.setProperty(Constants.Configuration.MESSAGE_TYPE,
                "application/soap+fastinfoset");

        options.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-16");


        EndpointReference targetEPR = new EndpointReference(

                "http://127.0.0.1:1237/axis2/services/AddressBookService");

        options.setTo(targetEPR);


        // /////////////////////////////////////////////////////////////////////



    serviceClient.setOptions(options);


        /*

         * Creates an Entry and stores it in the AddressBook.

         */



        // QName of the target method 

        QName opAddEntry = new QName("http://service.addressbook.sample", "addEntry");



        /*

         * Constructing a new Entry

         */

        Entry entry = new Entry();



        entry.setName("Abby Cadabby");

        entry.setStreet("Sesame Street");

        entry.setCity("Sesame City");

        entry.setState("Sesame State");

        entry.setPostalCode("11111111111111111111111111111111111111111111111111111111111111111111111111111");



        // Constructing the arguments array for the method invocation

        Object[] opAddEntryArgs = new Object[] { entry };



        // Invoking the method

        serviceClient.invokeRobust(opAddEntry, opAddEntryArgs);



        /*

         * Fetching an Entry from the Address book

         */



        // QName of the method to invoke 

        QName opFindEntry = new QName("http://service.addressbook.sample", "findEntry");



        //

        String name = "Abby Cadabby";



        Object[] opFindEntryArgs = new Object[] { name };

        Class[] returnTypes = new Class[] { Entry.class };


        Object[] response = serviceClient.invokeBlocking(opFindEntry,

                opFindEntryArgs, returnTypes); 


        Entry result = (Entry) response[0];



        if (result == null) {

            System.out.println("No entry found for " + name);

            return;

        } 



        System.out.println("Name   :" + result.getName());

        System.out.println("Street :" + result.getStreet());

        System.out.println("City   :" + result.getCity());

        System.out.println("State  :" + result.getState());

        System.out.println("Postal Code :" + result.getPostalCode());


    }

}
A: 

Read "How to Enable Fast Infoset in Axis2/Java". Hope it helps.

Alexander Philippou
I've been using that document as the basis for my code. It's not working. I was hoping for something a bit more insightful.
Jack BeNimble