我試圖開發安全的Web服務與SSL/HTTPS
。所以我創建的服務器&客戶端密鑰庫文件按照(link)及以下的服務器&客戶端的代碼,但客戶端代碼被拋出異常如下:發行啓用SSL爲Axis2 Web服務
com.sun.xml.ws.model.RuntimeModelerException: A WebService annotation is not present on class: com.heb.service.WpcimService
at com.sun.xml.ws.model.RuntimeModeler.getPortTypeName(RuntimeModeler.java:1604)
at com.sun.xml.ws.model.RuntimeModeler.getPortTypeName(RuntimeModeler.java:1597)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:413)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:433)
at javax.xml.ws.Service.getPort(Unknown Source)
at com.heb.client.WpcimClient.main(WpcimClient.java:32)
Server代碼:
public class SampleWebService {
public String method(String plainNumericCCNum)
{
return value;
}
客戶端代碼:
import java.net.URL;
import javax.xml.ws.Service;
import javax.xml.namespace.QName;
public class WebServiceClient {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Wpcim Client");
try
{
System.setProperty("javax.net.ssl.trustStore","d:/client.keystore");
System.setProperty("javax.net.ssl.trustStorePassword","changeit");
URL url = new URL("https://localhost:8443/Mywebservice/services/SampleWebService?wsdl");
QName qname = new QName("http://service.client.com", "SampleWebService");
Service service = Service.create(url, qname);
SampleWebService hello = service.getPort(SampleWebService.class);
System.out.println(hello.method("1234"));
}catch(Exception ex){
ex.printStackTrace();
}
}
}
請幫我弄清楚,這可能是什麼問題? 在此先感謝。
'com.heb.service.WpcimService'在哪裏? –
抱歉,由於審計目的,我將類名重命名爲SampleWebService。所以第一個是你問的那個。 – user1280096