Web サービスで fastinfoset 圧縮を有効にしようとしています。ただし、クライアントからの要求に応じてコンテンツ タイプを変更するのに問題があります。少なくとも、それが圧縮されていない理由だと思います。
いろいろ試してみましたが、コンテンツタイプは常に「text/xml」のままです。私が現在設定している方法では、「application/soap+fastinfoset」として通過することになっていると確信しています。私はスタンドアロンとして Axis2 を実行していますが、問題はコンテンツ タイプ ヘッダーが変更されていないことだと思います。
別のオプションを「UTF-8」から「UTF-16」に変更でき、ヘッダーに表示されたため、オプション自体がリクエストに設定されていることがわかりました。TCPMonitor からの現在のヘッダー出力は次のとおりです。
POST /axis2/services/AddressBookService HTTP/1.1
コンテンツ タイプ: テキスト/xml; 文字セット=UTF-16
SOAPAction: "urn:anonRobustOp"
ユーザーエージェント: Axis2
ホスト: 127.0.0.1:1237
Transfer-Encoding: チャンク
クライアントコードを以下に示します。どんな助けでも大歓迎です。
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());
}
}