刚开始学基于java的web service从网上找了一段代码如下:
代理接口:
package com.qdl.dao;
import java.rmi.Remote;
public interface HelloClientInterface extends Remote{
public String getName(String name) throws java.rmi.RemoteException;
}
测试程序:
package com.qdl.client;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Service;
import com.qdl.dao.HelloClientInterface;
public class TestHelloClient {
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自动生成方法存根
System.out.println("Start...");
try{
String wsdlUrl = "http://localhost:8080/axis/SayHello.jws?wsdl";
String nameSpaceUri = "http://localhost:8080/axis/SayHello.jws";
//注意下面的serviceName和portName,
//http://localhost/webservice/SayHello.jws?wsdl页面的xml最下端有
String serviceName = "SayHelloService";
String portName = "SayHello";
ServiceFactory serviceFactory = ServiceFactory.newInstance();
Service afService = serviceFactory.createService(new URL(wsdlUrl), new QName(nameSpaceUri, serviceName));
HelloClientInterface proxy = (HelloClientInterface) afService.getPort(new QName(nameSpaceUri, portName), HelloClientInterface.class);
System.out.println("返回信息是:" + proxy.getName("zhangsan"));
}catch(Exception ex){
ex.printStackTrace();
}
}
}
是第二种部署方法
问题是总出现入戏错误提示:
javax.xml.rpc.ServiceException: Incompatible service endpoint interface: com.qdl.dao.HelloClientInterface
at org.apache.axis.client.Service.getPort(Service.java:441)
at org.apache.axis.client.Service.getPort(Service.java:330)
at com.qdl.client.TestHelloClient.main(TestHelloClient.java:27)
求高手帮忙