Javaのaxis1.4でxml電文をSOAPRequestにして送信
なんかaxisでやってるとSOAPMessageとかいろいろめんどくさい感じなんですがその辺生でやりとりしたい場合に。 org.apache.http.client.HttpClient(4.1系)を利用して、HTTPでリクエストを送る。
ポイントは"SOAPAction"をHTTPヘッダに付与してあげること。これないとaxis1.4で作ったスタブはエラー返します(axis2系はわかりません)。
// SOAP request(xml) read-in File req_xml = new File("test/xml/request.xml"); // SOAP request send HttpPost post = new HttpPost("http://localhost:8080/test/api/"); post.setEntity(new InputStreamEntity(new FileInputStream(req_xml), req_xml.length())); post.setHeader("Content-type", "text/xml; charset=UTF-8"); post.setHeader("SOAPAction", ""); HttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(post); // SOAP response(xml) get String res_xml = EntityUtils.toString(response.getEntity());
ちなみに電文自体を取得するには
// get result from server AccountType ret = (AccountType)call.invoke(new Object[] { }); // get request/response(XML) String request = call.getMessageContext().getRequestMessage().getSOAPPartAsString(); String response = call.getMessageContext().getResponseMessage().getSOAPPartAsString();
という感じでinvokeした後、MessageContextから拾ってくればよいです。
Windowsで SSH+SVNならSubclipseよりSubversive
EclipseのダウンロードランキングだとSubclipseが上に来てたんですが、どうもWindowsだとtortoiseSVN入れてごにょごにょしないと、SSH+SVNのリポジトリを扱うにはうまくいかない気配なので、そういうのめんどくさいって人は素直にSubversive使うのがよいです。
Redmineにdigest認証
チュートリアルの通りapache+passengerでVirtualHostでポート8000にした例。
まずdigestファイルを作る。
# mkdir /var/digestpass # htdigest -c /var/digestpass/.digest "redmine_auth" redmine Adding password for redmine in realm redmine_auth. New password: Re-type new password:
httpd.confに設定。
# vi /etc/httpd/conf/httpd.conf --- <VirtualHost *:8000> ServerName www.redmine.my.jp DocumentRoot /var/lib/redmine/public <Directory "/var/lib/redmine/public"> AllowOverride All Order allow,deny Allow from all </Directory> <Location /> AuthType Digest AuthName "redmine_auth" AuthUserFile /var/digestpass/.digest Require valid-user </Location> </VirtualHost> ---
再起動。
# service httpd restart
あとはhtdigestで作成したユーザ名(ここではredmine)/パスワードでdigest認証できるはず。
Mac版 Eclipse4.2の日本語化手順
なんかうまくいかないなーと思ったらFinderで作業しててファイルのコピペミスってたというオチ。やり方自体はちゃんとやれば超簡単。
■用意するもの
・Eclipse 4.2 (お好みで。今回はJava屋さんっぽくJ2EE版を利用)
・Pleiades 本体(最新版。今回は1.3.4)
■手順
1. EclipseとPleiadesをブラウザでダウンロード
2. ダウンロードフォルダに移動、解凍
$ cd ~/Downloads $ tar xzvf eclipse-jee-juno-macosx-cocoa-x86_64.tar.gz $ mkdir pleiades # 解凍用ディレクトリ作り $ unzip pleiades_1.3.4.zip -d pleiades/ $ ls eclipse pleiades
3. プラグインを突っ込む
$ cp -a pleiades/* eclipse/ # featureとかpluginsとかコピー $ ls eclipse/plugins/jp.sourceforge.mergedoc.pleiades/pleiades.jar # 確認 eclipse/plugins/jp.sourceforge.mergedoc.pleiades/pleiades.jar
4. eclipse.iniを書き換える
$ vi eclipse/Eclipse.app/Contents/MacOS/eclipse.ini ---- (末尾に追加) -javaagent:../../../plugins/jp.sourceforge.mergedoc.pleiades/pleiades.jar ----
5. 適当な場所(ここでは/Applications)に配置し起動
$ mv eclipse /Applications/eclipse4.2j2ee/ # ついでにリネームしておいた $ cd /Applications/eclipse4.2j2ee/ $ ./eclipse -clean
以上です。注意点としては……Eclipse、クッソ重いってとこですかね……
CentOS6系統でsetupコマンドを出す
なんか最小(minimal)インストールだとsetupコマンドができなくなってたので。あれ無しでnetwork設定とかiptables設定とかめんどくさい。。。という人向け。
# yum install -y setuptool ntsysv system-config-network-tui system-config-firewall-tui
ただこれだとSELinuxの無効化はできないままなので、ここは手でやる。(yumで追加する方法あれば教えてください)
# vi /etc/sysconfig/selinux
SELINUX=disabled#その後再起動
にしても最小Cent6、lsofもwgetも入ってないし、Cent系は毎回やること極端な気がしますなー