java - Having trouble generating WebService artifacts -
i'm having trouble generating message , response artifacts web service. meet error in cmd when try:
c:\users\kingmarkmcc\workspace\webservicejx>wsgen -cp -keep . webserviceimp option "-classpath" requires argument
here webserviceinterface
:
package cacheserver; import javax.jws.webmethod; import javax.jws.webservice; import javax.jws.soap.soapbinding; import javax.jws.soap.soapbinding.style; @webservice @soapbinding(style= style.document) public interface webserviceinterface { @webmethod object get(object k); @webmethod void put(object k, object v); @webmethod void remove(object k); @webmethod void flush(); @webmethod int size(); }
and below implementation of webservice
package cacheserver;
import java.util.linkedhashmap; import java.util.map; import javax.jws.webservice; @webservice(endpointinterface = "cacheserver.webserviceinterface") public class webserviceimp implements webserviceinterface{ cachedatastruct cache; webserviceimp(int i){ cache = new cachedatastruct(i); } //getting cache @override public object get(object k){ system.out.println("get requested"); return getter(k); } private object getter(object k){ return cache.get(k); } //putting cache @override public void put(object k, object v){ system.out.println("put requested"); putter(k,v); } private void putter(object k, object v){ cache.put(k, v); } //removing cache @override public void remove(object k){ system.out.println("remove requested"); remover(k); } private void remover(object k){ cache.remove(k); } //getting size of cache @override public int size(){ system.out.println("size requested"); return sizer(); } private int sizer(){ return cache.size(); } //flushing cache @override public void flush(){ system.out.println("flush requested"); flusher(); } private void flusher(){ cache.flush(); } class cachedatastruct extends linkedhashmap<object,object>{ private static final long serialversionuid = -8892618408950826874l; public final int cachesize; private final static float loadfactor =0.75f; protected boolean removeeldestentry(map.entry<object, object> eldest) { return size() > cachesize; } public cachedatastruct(int cachesize){ super(cachesize,loadfactor,true); this.cachesize=cachesize; } void flush(){ clear(); system.out.println("cache has been cleared."); } } }
any generating artifacts appreciated!
after analysis, have picked first challenge here lies within service implementation bean (sib) webserviceimp. sib using invalid constructor : package access contructor, , expose service need add public no-arg constructor.
as defined jsr 181, class annotated javax.jws.webservice must have default public constructor. sib class must top level class or static inner class.
example of sib constructors:
public webserviceimp() {} public webserviceimp(int i) { cache = new cachedatastruct(i); }
after above changes , after compiling(javac cacheserver/*.java), can run wsgen command or run below command (while in src folder):
wsgen -cp "." -wsdl cacheserver.webserviceimp
also find way of passing argument rather using constructor in sib, maybe delegate pojo instantiation of object requiring arg constructor.
Comments
Post a Comment