Perl Java Web n 1 Perl SOAP Lite








![通常の回避策(UTF 8フラグの除去) 文字列 $_ 中のUTF 8フラグを除去する [1] unpack して pack する $_ = pack 通常の回避策(UTF 8フラグの除去) 文字列 $_ 中のUTF 8フラグを除去する [1] unpack して pack する $_ = pack](https://slidetodoc.com/presentation_image/3e10dc04988cbdd6eb2fdc2cfa43e05b/image-9.jpg)




















- Slides: 29


Perl と Java で異言語 Web サービス連携 n はじめに 1. Perl で SOAP: : Lite を使う n 2. Perl と Java の業務アプリケーション n 3. 各種 Adapter の紹介 Apache Axis で Java と連携 n 2004/12/16 株式会社ドリーム・アーツでの事例紹介 DA: : API フレームワーク n 4. SOAP, 日本語文字コード WSDL, WSDL 2 Java, Type Mapping 問題 Shibuya Perl Mongers テクニカルトーク #5 Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 2

1. Perl で SOAP: : Lite を使う Shibuya Perl Mongers テクニカルトーク #5 “Lite”な割には「軽く」ない… 2004/12/16 3


tcpmon で SOAPメッセージをキャプチャ n TCPモニタを起動する n java org. apache. axis. utils. tcpmon 2004/12/16 Shibuya Perl Mongers テクニカルトーク #5 Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 5

Perlクライアントの例 (SOAP: : Lite) #!/usr/bin/perl use SOAP: : Lite(); my $soap = SOAP: : Lite ->uri('urn: DA/API/Tests') ->proxy('http: //localhost: 8001/service/soap/') ->new; local [email protected]; my $som = eval { $soap->add({ a => 123, b => 456, c => 789, }); }; if ([email protected]) { die [email protected]; } if ($som->fault) { die $som->faultstring; } my $result = $som->result; print "result='$result'n"; exit(0); 2004/12/16 Shibuya Perl Mongers テクニカルトーク #5 Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 6


SOAP: : Lite の typelookup Perl : 型のない言語 n _typelookup => { base 64 => [10, sub {$_[0] =~ /[^x 09x 0 ax 0 dx 20 -x 7 f]/}, 'as_base 64'], 'int' => [20, sub {$_[0] =~ /^[+-]? (d+)$/ && $1 <= 2147483648; }, 'as_int'], float => [30, sub {$_[0] =~ /^(-? (? : d+(? : . d*)? |. d+|Na. N|INF)| ([+-]? )(? =d|. d)d*(. d*)? ([Ee]([+-]? d+))? )$/}, 'as_float'], string => [40, sub {1}, 'as_string'], 'long' => [25, sub {$_[0] =~ /^[+-]? (d+)$/ && $1 <= 9223372036854775807; }, 'as_long'], }, 【マルチバイトでもbase 64エンコードせず強制的に文字列として返す】 $self->{_typelookup}->{string} = [ 1, sub {1}, 'as_string']; 2004/12/16 Shibuya Perl Mongers テクニカルトーク #5 Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 8
![通常の回避策UTF 8フラグの除去 文字列 中のUTF 8フラグを除去する 1 unpack して pack する pack 通常の回避策(UTF 8フラグの除去) 文字列 $_ 中のUTF 8フラグを除去する [1] unpack して pack する $_ = pack](https://slidetodoc.com/presentation_image/3e10dc04988cbdd6eb2fdc2cfa43e05b/image-9.jpg)
通常の回避策(UTF 8フラグの除去) 文字列 $_ 中のUTF 8フラグを除去する [1] unpack して pack する $_ = pack ( 'C*', unpack ( 'C*', $_ ) ); もっと 効率的 [2] pack 'C 0' を使う $_ = pack 'C 0 A*', $_; from MT/XMLRPCServer. pm at www. movabletype. org. ## The following subroutine strips the UTF 8 flag from a string, thus ## forcing it into a series of bytes. "pack 'C 0'" is a magic way of ## forcing the following string to be packed as bytes, not as UTF 8. 2004/12/16 Shibuya Perl Mongers テクニカルトーク #5 Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 9

強硬な回避策(UTF 8フラグの除去) n XML-Parser にパッチを当てる(荒技) --- XML-Parser-2. 34 -orig/Expat. xs Mon Jul 28 23: 41: 10 2003 +++ XML-Parser-2. 34/Expat. xs Fri Aug 27 08: 36: 39 2004 @@ -17, 6 +17, 8 @@ #undef convert +#undef Sv. UTF 8_on + #include "patchlevel. h" #include "encoding. h" # patch –p 1 < XML-Parser-2. 34 -no_utf 8. patch → ややこしいことは考えなくて済む! 2004/12/16 Shibuya Perl Mongers テクニカルトーク #5 Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 10


株式会社ドリーム・アーツの主力製品 【インスイート エンタープライズ】 2004/12/16 Shibuya Perl Mongers テクニカルトーク #5 Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 12


「INSUITE Enterprise」と「ひびき」の比較 INSUITE Enterpirse ひびき カテゴリ EIP, グループウェア 業務アプリ SALES 開発言語 Perl, C 開発環境 vi 開発者 oldtype 2004/12/16 Shibuya Perl Mongers テクニカルトーク #5 PROJECT 異言語連携 (SOAP) Java Eclipse 異文化交流 (相互理解) newtype Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 14

4. DA: : API フレームワーク Shibuya Perl Mongers テクニカルトーク #5 各種 Adapter の紹介 2004/12/16 15

DA: : API フレームワークの構成図 Web I/F layer POST-XML Adapter sudo require user & group Shibuya Perl Mongers テクニカルトーク #5 SOAP Adapter Authz layer DA: : Adapter: : Basic. Auth スケジュール 登録・更新 削除・検索 ユーザ・グループ 情報の参照 : Authen layer DA: : Adapter: : Create. Session Command Adapter DA: : API modules Web I/F の実装 2004/12/16 Adaptation layer DA: : Adapter: : API HTML: : Template cgi-bin Web Browser Implementation layer cmd tools SOAP Client HTTP Client 実装(メンテナンス)する部分はここだけ 各Adapterがインタフェースを自動生成 Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 16




Webサービスの設定方法 n . htaccess (httpd. conf) で設置可能に <Location /service/soap/> order deny, allow IPアドレスの制限 deny from allow from 127. 0. 0. 1 192. 168. Auth. Name HTTP_Basic_Authentication Auth. Type Basic Perl. Module ユーザ認証の設定 DA: : Adapter: : Basic. Auth Perl. Authen. Handler DA: : Adapter: : Basic. Auth require valid-user Set. Handler perl-script Perl. Module DA: : Adapter: : SOAP Service の設定 Perl. Handler DA: : Adapter: : SOAP Perl. Set. Var dispatch_to "DA: : API: : Tests, DA: : API: : Sample" Perl. Set. Var options "compress_threshold => 10000" Options +Exec. CGI Perl. Set. Var SOAP_default_ie UTF-8 Perl. Set. Var SOAP_default_oe UTF-8 Perl. Set. Var SOAP_typelookup string 入出力エンコーディング設定 </Location> 2004/12/16 Shibuya Perl Mongers テクニカルトーク #5 Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 20

4. Apache Axis で Java と連携 Shibuya Perl Mongers テクニカルトーク #5 WSDLファイルとJavaスタブコード 2004/12/16 21

Apache Axis インストールするソフトウェア群 n (1) J 2 SDK 1. 4. 2_05 . . . j 2 sdk-1_4_2_05 -windows-i 586 -p. exe (2) Jakarta Tomcat 4. 1. 31 . . . jakarta-tomcat-4. 1. 31. exe (3) Apache Axis 1. 2 RC 1 . . . axis-1_2 RC 1 -bin. zip (4) JAF 1. 0. 2 . . . jaf-1_0_2 -upd. zip (5) javamail 1. 3. 1 . . . javamail-1_3_1. zip 2004/12/16 Shibuya Perl Mongers テクニカルトーク #5 Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 22

Javaクライアントの例 (Apache Axis) import import org. apache. soap. Constants; org. apache. soap. rpc. *; org. apache. soap. transport. http. SOAPHTTPConnection; java. net. URL; java. util. Vector; // javac SOAPClient. Tests. java // java SOAPClient. Tests public class SOAPClient. Tests { public static void main(String[] args) { try { // URLの指定 URL url = new URL("http: //localhost: 8001/service/soap/"); // Callオブジェクトを生成 Call call = new Call(); // ユーザ認証の設定 org. apache. soap. transport. http. SOAPHTTPConnection soap. Transport = new org. apache. soap. transport. http. SOAPHTTPConnection(); soap. Transport. set. User. Name(“username"); soap. Transport. set. Password("password"); call. set. SOAPTransport(soap. Transport); // ターゲットとなるURIを指定 call. set. Target. Object. URI("urn: DA/API/Tests"); // ターゲットとなるメソッドを指定 call. set. Method. Name("add"); // 直列化のスタイルを指定 call. set. Encoding. Style. URI(Constants. NS_URI_SOAP_ENC); // パラメータの設定 Vector params = new Vector(); params. add. Element(new Parameter("a", String. class, "123", null)); params. add. Element(new Parameter("b", String. class, "456", null)); params. add. Element(new Parameter("c", String. class, "789", null)); call. set. Params(params); // 呼び出しを実行 String SOAPAction. URI = ""; Response resp = call. invoke(url, SOAPAction. URI); // 戻り値を取得 Parameter ret = resp. get. Return. Value(); System. out. println(ret. get. Value()); } catch (Exception e) { e. print. Stack. Trace(); } } 2004/12/16 } Shibuya Perl Mongers テクニカルトーク #5 Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 23

WSDL 2 Java WSDLファイルからJavaのスタブコードを自動作成 n java org. apache. axis. wsdl. WSDL 2 Java ISAPI. wsdl Javaクライアント. /jp/co/dreamarts/insuite/DA/API/WSDL/Facility. Info. java. /jp/co/dreamarts/insuite/DA/API/WSDL/Fa. Schedule. Info. java. /jp/co/dreamarts/insuite/DA/API/WSDL/Group. Info. java. /jp/co/dreamarts/insuite/DA/API/WSDL/ISAPIBinding. Stub. java. /jp/co/dreamarts/insuite/DA/API/WSDL/ISAPIService. Locator. java. /jp/co/dreamarts/insuite/DA/API/WSDL/Schedule. Info. java 2004/12/16 Shibuya Perl Mongers テクニカルトーク #5 Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 24

WSDL とは? n WSDL (Web Services Description Language) n Webサービスを記述するための外部仕様(入出力仕様書) n サービスのインターフェースや、提供場所、実行方法などの情報を記述 (例) SOAP メッセージ (XML) WSDL ファイル (XML) リクエスト 入出力仕様書 network クライアント Windows Java (Apache Axis) 2004/12/16 Shibuya Perl Mongers テクニカルトーク #5 レスポンス SOAP メッセージ (XML) サーバ Linux mod_perl (SOAP: : Lite) Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 25

WSDLファイルの例 2004/12/16 Shibuya Perl Mongers テクニカルトーク #5 Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 26

Apache Axis (Java) の Type Mapping 問題 2004/12/16 WSDL type Java Type xsd: string java. lang. String xsd: int java. lang. Integer xsd: long java. lang. Long xsd: short java. lang. Short xsd: float java. lang. Float xsd: double java. lang. Double xsd: boolean java. lang. Boolean xsd: byte java. lang. Byte xsd: integer java. math. Big. Integer xsd: decimal java. math. Big. Decimal Shibuya Perl Mongers テクニカルトーク #5 Java Type (nillable) Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 27

何が問題か? xsd: integer n 無条件で java. math. Big. Integer にマッピング n 多倍長整数なのでパフォーマンス悪化 n xsd: int n nillable=“false” では int 宣言となる n nillable=“true” では java. lang. Integer 型を使用する (nullを許可するため) n int配列で nillable=false を指定する方法が不明 n int配列の要素にnullを許可したい場合… xsd: int が使えないので xsd: integer を使うしかない? n 2004/12/16 Shibuya Perl Mongers テクニカルトーク #5 Copyright © 2004 Dream. Arts Corporation. All Rights Reserved. 28

Peal soap
Java soap xml 파싱
Perl web framework
Sonrise lite
Hecvat
Photomod lite
Hias moodle
Family tree lite
Bas gartner
Katarzyna smalisz-skrzypczyk hematolog
G.lite enabled
Coflex tlc calamine lite 2 layer compression kit
Afbit lite
Hdx file huawei
Rdfa lite
Poker lite
Example of habits
Ess lite
Caiq lite
Inspiration lite
E spis lite
Mcs lite
Pabg m lite
Depositary-lite function for aifs
Lite-ng.1x001.com
Edms eil
Paratext lite
Lite temeraria domanda riconvenzionale contributo unificato
Amministratore di sostegno lite tra fratelli
Dtp lite