{"id":177,"date":"2008-12-22T23:58:56","date_gmt":"2008-12-23T03:58:56","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=177"},"modified":"2011-04-25T08:57:33","modified_gmt":"2011-04-25T13:57:33","slug":"revist-axis-14","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=177","title":{"rendered":"Revist Axis 1.4"},"content":{"rendered":"<p>We have a legacy Axis1 1.4 (not the Axis2 1.4) web services implementation and it&#8217;s causing interoperability issues. So we need a revisit :(<\/p>\n<p><strong>Overview<\/strong><br \/>\n-It&#8217;s a SOAP-RPC implementation and implements jaxrpc.jar and saaj.jar (SOAP with attachment API)<br \/>\n-Implemented as a chain of message handlers<br \/>\n&#8211;<strong><em>Defaults to<\/em><\/strong> RPC\/Encoded (SOAP section 5 encoding rules) so NOT WS-I compliant?!<br \/>\n-Architecture guide is <a href=\"http:\/\/ws.apache.org\/axis\/java\/architecture-guide.html\" target=\"_blank\">here<\/a><br \/>\n-It&#8217;s compiled in axis.jar file<br \/>\n&#8211; See <a href=\"http:\/\/finallyigotit.blogspot.com\/2009\/05\/jax-rpc-vs-jax-ws.html\">this blog<\/a> for an overview of differences between jax-rpc and jax-ws.<\/p>\n<p><strong>Install<\/strong><br \/>\n-Download and unzip Axis 1.4 (axis-bin-1_4.zip)<br \/>\n-Download and install Tomcat (I used apache-tomcat-4.1.39.zip)<br \/>\n-Copy the axis directory from axis distribution&#8217;s webapps directory into Tomcat&#8217;s webapps directory<br \/>\n-Start Tomcat<br \/>\n-Point browser to http:\/\/127.0.0.1:8080\/axis\/ (should see the Axis welcome page)<br \/>\n-Click Validation link (should see no errors)<br \/>\n-Test a SOAP endpoint: http:\/\/localhost:8080\/axis\/services\/Version?method=getVersion<br \/>\n-Test a JWS endpoint: http:\/\/localhost:8080\/axis\/EchoHeaders.jws?method=list<\/p>\n<p><strong>Deploy Stock Sample Web Services<\/strong><br \/>\n-Create a deploy.bat file in sample directory (i.e. samples\/stock):<\/p>\n<pre>set AXIS_HOME=C:\\jml\\sw\\org\\apache\\axis\\axis-1_4\r\nset AXIS_LIB=%AXIS_HOME%\\lib\r\nset AXISCLASSPATH=%AXIS_LIB%\\axis.jar;%AXIS_LIB%\\commons-discovery-0.2.jar;%AXIS_LIB%\\commons-logging-1.0.4.jar;%AXIS_LIB%\\jaxrpc.jar;%AXIS_LIB%\\saaj.jar;%AXIS_LIB%\\log4j-1.2.8.jar;%AXIS_LIB%\\xml-apis.jar;%AXIS_LIB%\\xercesImpl.jar;%AXIS_LIB%\\wsdl4j-1.5.1.jar\r\njava -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient -lhttp:\/\/localhost:8080\/axis\/services\/AdminService deploy.wsdd<\/pre>\n<p>-Run deploy.bat to deploy<br \/>\n-Restart Tomcat<\/p>\n<p><strong>WSDD<\/strong><\/p>\n<pre lang=\"xml\">\r\n<deployment xmlns=\"http:\/\/xml.apache.org\/axis\/wsdd\/\"\r\n            xmlns:java=\"http:\/\/xml.apache.org\/axis\/wsdd\/providers\/java\">\r\n  <!-- define the logging handler configuration -->\r\n <handler name=\"track\" type=\"java:samples.userguide.example4.LogHandler\">\r\n  <parameter name=\"filename\" value=\"MyService.log\"\/>\r\n <\/handler>\r\n \r\n <!-- define the service, using the log handler we just defined -->\r\n <service name=\"LogTestService\" provider=\"java:RPC\">\r\n  <requestFlow>\r\n   <handler type=\"track\"\/>\r\n  <\/requestFlow>\r\n \r\n  <parameter name=\"className\" value=\"samples.userguide.example4.Service\"\/>\r\n  <parameter name=\"allowedMethods\" value=\"*\"\/>\r\n <\/service>\r\n<\/deployment>\r\n<\/pre>\n<p><strong>Test Stock Sample Web Services<\/strong><br \/>\n-Create a test script in the %AXIS_HOME% directory<\/p>\n<pre>set AXIS_HOME=C:\\jml\\sw\\org\\apache\\axis\\axis-1_4\r\nset AXIS_LIB=%AXIS_HOME%\\lib\r\nset AXISCLASSPATH=%AXIS_LIB%\\axis.jar;%AXIS_LIB%\\commons-discovery-0.2.jar;%AXIS_LIB%\\commons-logging-1.0.4.jar;%AXIS_LIB%\\jaxrpc.jar;%AXIS_LIB%\\saaj.jar;%AXIS_LIB%\\log4j-1.2.8.jar;%AXIS_LIB%\\wsdl4j-1.5.1.jar\r\njava -cp .;%AXISCLASSPATH% samples.stock.GetQuote -lhttp:\/\/localhost:8080\/axis\/servlet\/AxisServlet -uuser2 XXX<\/pre>\n<pre lang=\"ksh\">\r\n#!\/bin\/ksh\r\nexport AXIS_LIB=$AXIS_HOME\/lib\r\necho $AXIS_LIB\r\nexport AXISCLASSPATH=$AXIS_LIB\/axis.jar:$AXIS_LIB\/commons-discovery-0.2.jar:$AXIS_LIB\/commons-logging-1.0.4.jar:$AXIS_LIB\/jaxrpc.jar:$AXIS_LIB\/saaj.jar:$AXIS_LIB\/log4j-1.2.8.jar:$AXIS_LIB\/xml-apis.jar:$AXIS_LIB\/xercesImpl.jar:$AXIS_LIB\/wsdl4j-1.5.1.jar\r\necho $AXISCLASSPATH\r\n$JAVA_HOME\/bin\/java -cp $AXISCLASSPATH org.apache.axis.client.AdminClient -lhttp:\/\/localhost:9980\/axis\/services\/AdminService deploy.wsdd<\/pre>\n<p>-Run it. Should get &#8220;XXX: 55.25&#8221;<br \/>\n-Alternatively, use SoapUI to test<br \/>\n*WSDL URL: http:\/\/localhost:8080\/axis\/services\/urn:xmltoday-delayed-quotes?wsdl<\/p>\n<p><strong>Test Stock Sample Web Services Using Java Code<\/strong><\/p>\n<pre lang=\"java\">public void testVersion() throws ServiceException, AxisFault{\r\n  String endpoint = \"http:\/\/localhost:8888\/axis\/services\/Version\";\r\n  Service service = new Service();\r\n  Call call = (Call)service.createCall();\r\n\r\n  call.setTargetEndpointAddress(endpoint);\r\n\r\n  String result = (String)call.invoke(\"getVersion\", null);\r\n  System.out.println(result);\r\n}\r\n\r\npublic void testStockGetQuote() throws ServiceException, AxisFault{\r\n  String endpoint = \"http:\/\/localhost:8888\/axis\/services\/urn:xmltoday-delayed-quotes\";\r\n  Service service = new Service();\r\n  Call call = (Call)service.createCall();\r\n\r\n  call.setTargetEndpointAddress(endpoint);\r\n  call.setUsername(\"user1\");\r\n  call.setPassword(\"pass1\");\r\n\r\n  String result = (String)call.invoke(\"test\", null);\r\n  System.out.println(result);\r\n\r\n  Float quote = (Float)call.invoke(\"getQuote\", new Object[]{\"XXX\"});\r\n  System.out.println(quote);\r\n}<\/pre>\n<p><strong>WSDL2Java<\/strong><br \/>\n&#8211;<a href=\"http:\/\/ws.apache.org\/axis\/java\/reference.html\">wsdl2java command options<\/a><br \/>\n-Sample client-side generation commands<\/p>\n<pre>\r\n@echo off\r\nset JAVA_CMD=\"%JAVA_HOME%\\bin\\java\"\r\nset AXIS_HOME=C:\\jml\\sw\\org\\apache\\axis\\axis-1_4\r\nset JAVA_OPTIONS=-Djava.ext.dirs=%AXIS_HOME%\\lib\\\r\nset CLASS_PATH=.\r\n\r\n%JAVA_CMD% %JAVA_OPTIONS% -cp %CLASS_PATH% org.apache.axis.wsdl.WSDL2Java stock.wsdl\r\n<\/pre>\n<p>-Generated client side classes<br \/>\n+For each entry in the type section<br \/>\n*A java class<br \/>\n*A holder if this type is used as an inout\/out parameter<br \/>\n+For each portType<br \/>\n*A java interface<br \/>\n+For each binding<br \/>\n*A stub class<br \/>\n+For each service<br \/>\n*A service interface<br \/>\n*A service implementation (the locator)<br \/>\n-Test code<\/p>\n<pre lang=\"java\">\r\npublic void testStockGetQuote2() throws ServiceException, RemoteException{\r\n  StockQuoteServiceService service = new StockQuoteServiceServiceLocator();\r\n  StockQuoteService port = service.getGetQuote();\r\n  ((org.apache.axis.client.Stub) port).setUsername(\"user1\");\r\n  ((org.apache.axis.client.Stub) port).setPassword(\"pass1\");\r\n\r\n  String test = port.test();\r\n  System.out.println(test);\r\n\r\n  float quote = port.getQuote(\"XXX\");\r\n  System.out.println(quote);\r\n}<\/pre>\n<p>-Server side binding with option &#8220;&#8211;server-side &#8211;skeletonDeploy true&#8221; or &#8220;-s -S true&#8221;<br \/>\n%JAVA_CMD% %JAVA_OPTIONS% org.apache.axis.wsdl.WSDL2Java -s -S true stock.wsdl<br \/>\n&#8211;<strong><em>Generated server side classes<\/em><\/strong><br \/>\n+For each binding<br \/>\n*A skeleton class<br \/>\n*An implementation template class<br \/>\n+For all services<br \/>\n*One deploy.wsdd file<br \/>\n*One undeploy.wsdd file<\/p>\n<p><strong>Java2WSDL<\/strong><br \/>\n-Create WSDL from Java interface<br \/>\n-From Java Interface<\/p>\n<pre lang=\"java\">\r\npackage java2wsdl;\r\n\r\npublic interface WidgetPrice {\r\n\tString getWidgetPrice(String widgetName);\r\n\tvoid setWidgetPrice(String widgetName, String widgetPrice);\r\n}\r\n<\/pre>\n<p>-Command<\/p>\n<pre>\r\n@echo off\r\necho JAVA_HOME: %JAVA_HOME%\r\nset JAVA_CMD=\"%JAVA_HOME%\\bin\\java\"\r\nrem set JAVAC_CMD=\"%JAVA_HOME%\\bin\\javac\"\r\n\r\nrem setting up axis1 env...\r\nset AXIS_HOME=C:\\jml\\sw\\org\\apache\\axis\\axis-1_4\r\n\r\nset JAVA_OPTIONS=-Djava.ext.dirs=%AXIS_HOME%\\lib\\\r\necho JAVA_OPTIONS: %JAVA_OPTIONS%\r\n\r\nset CLASS_PATH=..\\..\\bin\r\n\r\n%JAVA_CMD% %JAVA_OPTIONS% -cp %CLASS_PATH% org.apache.axis.wsdl.Java2WSDL -o widget.wsdl -l\"http:\/\/localhost:8080\/axis\/services\/WidgetPrice\" -n\"urn:WidgetPrice\" -p\"widget\" \"urn:WidgetPrice\" widget.WidgetPrice<\/pre>\n<p>-Got<\/p>\n<pre lang=\"xml\">\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<wsdl:definitions targetNamespace=\"urn:WidgetPrice\" xmlns:apachesoap=\"http:\/\/xml.apache.org\/xml-soap\" xmlns:impl=\"urn:WidgetPrice\" xmlns:intf=\"urn:WidgetPrice\" xmlns:soapenc=\"http:\/\/schemas.xmlsoap.org\/soap\/encoding\/\" xmlns:wsdl=\"http:\/\/schemas.xmlsoap.org\/wsdl\/\" xmlns:wsdlsoap=\"http:\/\/schemas.xmlsoap.org\/wsdl\/soap\/\" xmlns:xsd=\"http:\/\/www.w3.org\/2001\/XMLSchema\">\r\n<!--WSDL created by Apache Axis version: 1.4\r\nBuilt on Apr 22, 2006 (06:55:48 PDT)-->\r\n   <wsdl:message name=\"setWidgetPriceRequest\">\r\n      <wsdl:part name=\"in0\" type=\"soapenc:string\"\/>\r\n      <wsdl:part name=\"in1\" type=\"soapenc:string\"\/>\r\n   <\/wsdl:message>\r\n   <wsdl:message name=\"getWidgetPriceResponse\">\r\n      <wsdl:part name=\"getWidgetPriceReturn\" type=\"soapenc:string\"\/>\r\n   <\/wsdl:message>\r\n   <wsdl:message name=\"setWidgetPriceResponse\">\r\n   <\/wsdl:message>\r\n   <wsdl:message name=\"getWidgetPriceRequest\">\r\n      <wsdl:part name=\"in0\" type=\"soapenc:string\"\/>\r\n   <\/wsdl:message>\r\n   <wsdl:portType name=\"WidgetPrice\">\r\n      <wsdl:operation name=\"getWidgetPrice\" parameterOrder=\"in0\">\r\n         <wsdl:input message=\"impl:getWidgetPriceRequest\" name=\"getWidgetPriceRequest\"\/>\r\n         <wsdl:output message=\"impl:getWidgetPriceResponse\" name=\"getWidgetPriceResponse\"\/>\r\n      <\/wsdl:operation>\r\n      <wsdl:operation name=\"setWidgetPrice\" parameterOrder=\"in0 in1\">\r\n         <wsdl:input message=\"impl:setWidgetPriceRequest\" name=\"setWidgetPriceRequest\"\/>\r\n         <wsdl:output message=\"impl:setWidgetPriceResponse\" name=\"setWidgetPriceResponse\"\/>\r\n      <\/wsdl:operation>\r\n   <\/wsdl:portType>\r\n   <wsdl:binding name=\"WidgetPriceSoapBinding\" type=\"impl:WidgetPrice\">\r\n      <wsdlsoap:binding style=\"rpc\" transport=\"http:\/\/schemas.xmlsoap.org\/soap\/http\"\/>\r\n      <wsdl:operation name=\"getWidgetPrice\">\r\n         <wsdlsoap:operation soapAction=\"\"\/>\r\n         <wsdl:input name=\"getWidgetPriceRequest\">\r\n            <wsdlsoap:body encodingStyle=\"http:\/\/schemas.xmlsoap.org\/soap\/encoding\/\" namespace=\"urn:WidgetPrice\" use=\"encoded\"\/>\r\n         <\/wsdl:input>\r\n         <wsdl:output name=\"getWidgetPriceResponse\">\r\n            <wsdlsoap:body encodingStyle=\"http:\/\/schemas.xmlsoap.org\/soap\/encoding\/\" namespace=\"urn:WidgetPrice\" use=\"encoded\"\/>\r\n         <\/wsdl:output>\r\n      <\/wsdl:operation>\r\n      <wsdl:operation name=\"setWidgetPrice\">\r\n         <wsdlsoap:operation soapAction=\"\"\/>\r\n         <wsdl:input name=\"setWidgetPriceRequest\">\r\n            <wsdlsoap:body encodingStyle=\"http:\/\/schemas.xmlsoap.org\/soap\/encoding\/\" namespace=\"urn:WidgetPrice\" use=\"encoded\"\/>\r\n         <\/wsdl:input>\r\n         <wsdl:output name=\"setWidgetPriceResponse\">\r\n            <wsdlsoap:body encodingStyle=\"http:\/\/schemas.xmlsoap.org\/soap\/encoding\/\" namespace=\"urn:WidgetPrice\" use=\"encoded\"\/>\r\n         <\/wsdl:output>\r\n      <\/wsdl:operation>\r\n   <\/wsdl:binding>\r\n   <wsdl:service name=\"WidgetPriceService\">\r\n      <wsdl:port binding=\"impl:WidgetPriceSoapBinding\" name=\"WidgetPrice\">\r\n         <wsdlsoap:address location=\"http:\/\/localhost:8080\/axis\/services\/WidgetPrice\"\/>\r\n      <\/wsdl:port>\r\n   <\/wsdl:service>\r\n<\/wsdl:definitions><\/pre>\n<p>-Now generate server side binding classes<\/p>\n<pre>\r\n@echo off\r\necho JAVA_HOME: %JAVA_HOME%\r\nset JAVA_CMD=\"%JAVA_HOME%\\bin\\java\"\r\nset AXIS_HOME=C:\\jml\\sw\\org\\apache\\axis\\axis-1_4\r\nset JAVA_OPTIONS=-Djava.ext.dirs=%AXIS_HOME%\\lib\\\r\necho JAVA_OPTIONS: %JAVA_OPTIONS%\r\nset CLASS_PATH=.\r\n\r\n%JAVA_CMD% %JAVA_OPTIONS% -cp %CLASS_PATH% org.apache.axis.wsdl.WSDL2Java -o . -d session -s -S true -Nurn:WidgetPrice widget.wsdl2java widget.wsdl<\/pre>\n<p>-Implement\/fill in &#8220;WidgetPriceSoapBindingImpl&#8221; class<br \/>\n-Compile widget package and copy to Tomcat webapps\\axis\\WEB-INF\\classes<br \/>\n-Ran deploy<\/p>\n<pre>\r\nset AXIS_HOME=C:\\jml\\sw\\org\\apache\\axis\\axis-1_4\r\nset AXIS_LIB=%AXIS_HOME%\\lib\r\nset AXISCLASSPATH=%AXIS_LIB%\\axis.jar;%AXIS_LIB%\\commons-discovery-0.2.jar;%AXIS_LIB%\\commons-logging-1.0.4.jar;%AXIS_LIB%\\jaxrpc.jar;%AXIS_LIB%\\saaj.jar;%AXIS_LIB%\\log4j-1.2.8.jar;%AXIS_LIB%\\xml-apis.jar;%AXIS_LIB%\\xercesImpl.jar;%AXIS_LIB%\\wsdl4j-1.5.1.jar\r\nrem java -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient -lhttp:\/\/localhost:8080\/axis\/services\/AdminService deploy.wsdd\r\njava -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient -lhttp:\/\/localhost:8080\/axis\/services\/AdminService undeploy.wsdd<\/pre>\n<p>-Restart Tomcat<br \/>\n-Test service<\/p>\n<pre lang=\"java\">\r\n\tpublic void testGetWidgetPrice() throws ServiceException, AxisFault{\r\n\t\tString endpoint = \"http:\/\/localhost:8888\/axis\/services\/WidgetPrice\";\r\n\t\tService service = new Service();\r\n\t\tCall call = (Call)service.createCall();\r\n\t\t\r\n\t\tcall.setTargetEndpointAddress(endpoint);\r\n\t\t\r\n\t\tString result = (String)call.invoke(\"getWidgetPrice\", null);\r\n\t\tSystem.out.println(result);\r\n\t}<\/pre>\n<p><strong>Remote Administration<\/strong><br \/>\nNote that by default, the Axis server is configured to only accept administration requests from the machine on which it resides &#8211; if you wish to enable remote administration, you must set the &#8220;enableRemoteAdmin&#8221; property of the AdminService to true. To do this, find the &#8220;server-config.wsdd&#8221; file in your webapp&#8217;s WEB-INF directory. In it, you&#8217;ll see a deployment for the AdminService. Add an option as follows:<\/p>\n<pre lang=\"xml\">\r\n<service name=\"AdminService\" provider=\"java:MSG\">\r\n  <parameter name=\"className\" value=\"org.apache.axis.util.Admin\"\/>\r\n  <parameter name=\"allowedMethods\" value=\"*\"\/>\r\n  <parameter name=\"enableRemoteAdmin\" value=\"true\"\/>\r\n<\/service>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>We have a legacy Axis1 1.4 (not the Axis2 1.4) web services implementation and it&#8217;s causing interoperability issues. So we need a revisit :( Overview -It&#8217;s a SOAP-RPC implementation and implements jaxrpc.jar and saaj.jar (SOAP with attachment API) -Implemented as &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=177\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[40,22],"tags":[],"class_list":["post-177","post","type-post","status-publish","format-standard","hentry","category-jax-rpc","category-soa"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-2R","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=177"}],"version-history":[{"count":20,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/177\/revisions"}],"predecessor-version":[{"id":198,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/177\/revisions\/198"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}