You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by mcd99999 <mc...@gmail.com> on 2010/06/23 01:18:50 UTC

Axis2 - Client problem setting option for content type (fast-infoset)

Hello,

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");



	//options.setProperty(Constants.Configuration.MESSAGE_TYPE,

	//		"application/fastinfoset");



        System.out.println("set options to : " +
options.getProperty(Constants.Configuration.MESSAGE_TYPE));



        EndpointReference targetEPR = new EndpointReference(

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





        options.setTo(targetEPR);



	System.out.println("changed port to " + targetEPR);



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



	serviceClient.setOptions(options);



	System.out.println("set options to " + 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());

        



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

    }

}


-- 
View this message in context: http://old.nabble.com/Axis2---Client-problem-setting-option-for-content-type-%28fast-infoset%29-tp28966209p28966209.html
Sent from the Axis - User mailing list archive at Nabble.com.


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