我在爲Web服務生成消息和響應構件時遇到了一些問題。我在嘗試時遇到了cmd錯誤:生成WebService構件時遇到問題
C:\ Users \ KingMarkMcC \ workspace \ WebServiceJX> wsgen -cp -keep。 WebServiceImp選項 「-classpath」 需要一個參數
這裏是我的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();
}
而且我下面的實施WebService
包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 from 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 into 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 from 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.");
}
}
}
任何關於生成工件的幫助將非常感謝!