本來要試xmlrpc的實作,但是curl一直下載不下來,這又是個重要的套件,就改天再試了。
今晚試Axis2/c:http://axis.apache.org/axis2/c/core/
Axis2 和axis 不一樣,axis 用java/c++實作,而Axis2 是Java/C.
實作soap和rest這兩個web service。
參照安裝說明:http://axis.apache.org/axis2/c/core/docs/installationguide.html
下載:http://apache.cdpa.nsysu.edu.tw//ws/axis2/c/1_6_0/axis2c-src-1.6.0.tar.gz
解壓縮,因為有範例samples,所以先設它的安裝路徑,之後比較好找。
我的安裝路徑是在**/opt/axis2c/**
samples會用到系統路徑變數。
$ AXIS2C_HOME='/opt/axis2c'
$ export AXIS2C_HOME
進入源代碼目錄裏,
./configure 變成
./configure --prefix=${AXIS2C_HOME} --enable-libxml2.1=yes
手冊是寫--enable-libxml2,但是筆者的環境設定會error。
產生
checking pkg-config is at least version 0.9.0... yes
yes
checking for LIBXML2... configure: error: Package requirements (libxml-2.0) were not met:No package 'libxml-2.0' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.Alternatively, you may set the environment variables LIBXML2_CFLAGS
and LIBXML2_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
然後可以make,sudo make install
同理,sample,可按手冊上 設定。
AMQP Transport 不知道是做什麼用的,暫且不看,跳掉。
samples make好了之後,可以試run看看。
一個http 的server端服務 on 起來,會跑出很多訊息,
例如
[Sat Nov 5 06:58:05 2011] [debug] svc_builder.c(318) DLL path is : ..//services/Calculator/libCalculator.so
[Sat Nov 5 06:58:05 2011] [debug] svc_builder.c(318) DLL path is : ..//services/echo/libecho.so
[Sat Nov 5 06:58:05 2011] [debug] svc_builder.c(318) DLL path is : ..//services/math/libmath.so
[Sat Nov 5 06:58:05 2011] [debug] svc_builder.c(318) DLL path is : ..//services/mtom/libmtom.so
[Sat Nov 5 06:58:05 2011] [debug] svc_builder.c(318) DLL path is : ..//services/mtom_callback/libmtom_callback.so
[Sat Nov 5 06:58:05 2011] [debug] svc_builder.c(318) DLL path is : ..//services/notify/libnotify.so
[Sat Nov 5 06:58:05 2011] [debug] svc_builder.c(318) DLL path is : ..//services/sg_math/libadd.so
[Sat Nov 5 06:58:05 2011] [debug] om_element.c(1114) There are no child elements for the node
[Sat Nov 5 06:58:05 2011] [debug] svc_builder.c(318) DLL path is : ..//services/sg_math/libsub.so
[Sat Nov 5 06:58:05 2011] [debug] om_element.c(1114) There are no child elements for the node
[Sat Nov 5 06:58:05 2011] [debug] svc_builder.c(318) DLL path is : ..//services/sg_math/libmul.so
[Sat Nov 5 06:58:05 2011] [debug] om_element.c(1114) There are no child elements for the node
[Sat Nov 5 06:58:05 2011] [debug] svc_builder.c(318) DLL path is : ..//services/sg_math/libdiv.so
[Sat Nov 5 06:58:05 2011] [debug] om_element.c(1114) There are no child elements for the node
[Sat Nov 5 06:58:05 2011] [debug] svc_builder.c(318) DLL path is : ..//services/version/libversion.so
[Sat Nov 5 06:58:05 2011] [debug] phase_holder.c(139) Add handler AddressingInHandler to phase Transport
[Sat Nov 5 06:58:05 2011] [debug] phase_resolver.c(222) svc name is:div
[Sat Nov 5 06:58:05 2011] [debug] phase_resolver.c(139) Service name is : div
[Sat Nov 5 06:58:05 2011] [debug] phase_resolver.c(1123) Operation name is : div
samples 除了手冊上的 echo,math 服務之後,看來還有其他的服務。
而server端服務起來後,開一個shell,進入client 端目錄,
按手冊下指令,
[Sat Nov 5 07:01:37 2011] [debug] phase_holder.c(139) Add handler AddressingOutHandler to phase MessageOut
[Sat Nov 5 07:01:37 2011] [debug] op_client.c(888) Start:axis2_op_client_infer_transport
[Sat Nov 5 07:01:37 2011] [debug] op_client.c(954) End:axis2_op_client_infer_transport
[Sat Nov 5 07:01:37 2011] [debug] http_transport_sender.c(246) ctx_epr:http://localhost:9090/axis2/services/math
[Sat Nov 5 07:01:37 2011] [debug] http_transport_sender.c(805) using axis2 native http sender.
[Sat Nov 5 07:01:37 2011] [debug] http_sender.c(416) msg_ctx_id:urn:uuid:ad61e98e-07b6-1e11-395b-000c2966fa97
[Sat Nov 5 07:01:37 2011] [debug] http_transport_sender.c(822) OP name axutil_qname_get_localpart = http://www.w3.org/2004/08/wsdl/out-in
[Sat Nov 5 07:01:37 2011] [debug] soap_builder.c(945) identified soap version is soap12
[Sat Nov 5 07:01:37 2011] [debug] phase.c(210) Invoke the handler request_uri_based_dispatcher within the phase Transport
[Sat Nov 5 07:01:37 2011] [debug] phase.c(210) Invoke the handler AddressingInHandler within the phase Transport
[Sat Nov 5 07:01:37 2011] [info] Starting addressing in handler
[Sat Nov 5 07:01:37 2011] [debug] phase.c(210) Invoke the handler addressing_based_dispatcher within the phase Transport
[Sat Nov 5 07:01:37 2011] [debug] phase.c(210) Invoke the handler rest_dispatcher within the phase Dispatch
[Sat Nov 5 07:01:37 2011] [debug] phase.c(210) Invoke the handler soap_message_body_based_dispatcher within the phase Dispatch
[Sat Nov 5 07:01:37 2011] [debug] soap_body_disp.c(127) Checking for service using SOAP message body's first child's namespace URI : http://axis2/test/namespace1
[Sat Nov 5 07:01:37 2011] [debug] phase.c(210) Invoke the handler soap_action_based_dispatcher within the phase Dispatch
[Sat Nov 5 07:01:37 2011] [debug] soap_action_disp.c(89) Checking for service using SOAPAction is not implemented
[Sat Nov 5 07:01:37 2011] [debug] phase.c(210) Invoke the handler dispatch_post_conditions_evaluator within the phase PostDispatch
[Sat Nov 5 07:01:37 2011] [debug] phase.c(210) Invoke the handler context_handler within the phase PostDispatch
小結:
axis2/c 這個apache 基金會下的web service專案,
在編譯時,發了很長的時間,感覺是個很龐大的專案。和gsoap2比起來是複雜多了。
但是體現在除錯訊息上,倒是讓人很容易看出,server 啟動時,做了那些事情,client觸發時,
做了那些事情,很值得學習的地方,減少用gdb去trace 程式的時間。
axis2c 除了可以獨立像sample一樣自己完成http server的監聽功能,也可以做成apache或IIS的模組,不用自己一手包,彈性很大。
目前還未自己diy 一個模組,看看會不會比gsoap2 方便。
有rest的支援。
[http://axis.apache.org/axis2/c/core/docs/axis2c_manual.html#rest
](http://axis.apache.org/axis2/c/core/docs/axis2c_manual.html#rest<br />
)