代码之家  ›  专栏  ›  技术社区  ›  Jack BeNimble

Axis2和FastInfo集-无法获取要更改的内容类型

  •  0
  • Jack BeNimble  · 技术社区  · 15 年前

    我一直在尝试在我的web服务上启用fastinfoset压缩。但是,我在从客户端请求更改内容类型时遇到了一个问题。至少,我认为这就是为什么它没有压缩。

    我尝试了很多不同的方法,但内容类型始终保持为“text/xml”。我很确定它应该以“应用程序/soap+fastinfoset”的方式进行设置。我将Axis2作为一个独立的运行,但我认为问题是内容类型头没有改变。

    POST/axis2/services/AddressBookService HTTP/1.1

    SOAPAction:“瓮:另一个"

    用户代理:Axis2

    主持人:127.0.0.1:1237

    传输编码:分块

    客户端代码如下所示。非常感谢您的帮助。

    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());
    
    
        }
    
    }
    
    2 回复  |  直到 15 年前
        1
  •  2
  •   Kelum Senanayake Kelum Senanayake    12 年前

    -Daxis2.xml="location of axis2.xml" 
    

        2
  •  -1
  •   Alexander Philippou    15 年前

    阅读“ How to Enable Fast Infoset in Axis2/Java ". 希望有帮助。

    推荐文章