AXIOMでContent-Lengthを付ける方法
つまりはTransfer-Encoding: chunkedを無効にする方法です。
AXIOMのソースのCommonsHTTPTransportSenderを見てようやく分かった!
Options options = new Options(); EndpointReference endpointReference = new EndpointReference(endpoint); options.setTo(endpointReference); options.setTransportInProtocol(Constants.TRANSPORT_HTTP); options.setAction("\"http://〜/〜.asmx/〜\""); options.setProperty(MessageContextConstants.CHUNKED, "false"); ServiceClient sender = new ServiceClient(); sender.setOptions(options);
chunkedをfalseにしてしまえばContent-Lengthは自動的に付きました。
あとはBeanUtil.deserialize()を使って戻ってきたXMLをオブジェクトへマッピングしてやればOK。なんでchunkedで呼び出せないのかはもう少しHTTPの勉強をしないと分からないっぽい。とりあえずここまでが長かった…。
AxisServletのソースにはこんな記述があった。
/* My understand of Content-Length * HTTP 1.0 * -Required for requests, but optional for responses. * HTTP 1.1 * - Either Content-Length or HTTP Chunking is required. * Most servlet engines will do chunking if content-length is not specified. */
さてgzip圧縮へ手を伸ばすか?
っと、その前にAxisのスタブからもContent-Lengthをくっつける方法を調べておこう。デフォルトだとchunkedになっているので。そもそもchunkedでいけない理由も調べないとなぁ…。gzip圧縮の時にまたつまづくだろう。