web services - Persisting data in an axis object -
forgive me if dumb question, unfortunately have assignment due! running apache axis under tomcat , need deploy simple web service class, see below.
i installed counter file below "mycounter.jws" in /tomcat/webapps/axis/ folder. tomcat finds , makes corresponding mycounter.xml. use wsdl2java on xml file , client calls seem work, internal state not saved:
every time call mycounter.call client side, return value 1. seems constructor called before method call. how can make mycounter integer persists across requests?
public class mycounter { int mycounter; public mycounter() { mycounter = 0; } public int call() { mycounter++; return mycounter; } }
i think persisting maybe wrong word, think mean java class not instantiated every time call service.
see: https://axis.apache.org/axis/java/user-guide.html#scoped_services
so need change service definition yo achieve this.
i don't think jws files able configure session scope. docs say: https://axis.apache.org/axis/java/user-guide.html#jws_java_web_service_files_-_instant_deployment
quote:
important: jws web services intended simple web services. cannot use packages in pages, , code compiled @ run time can not find out errors until after deployment. production quality web services should use java classes custom deployment.
so if want use such features should consider using of other ways axis offers setup webservice. recommend using axis2 instead of axis1: http://axis.apache.org/axis2/java/core/
axis1 can quite complicated wsdd files setup. apart axis1 no more actively developed/maintained.
Comments
Post a Comment