我正在尝试使用Java中的端点将设备中的方法公开为Web服务。问题是,在创建端点时,我需要传入定义类的接口实现的实例,但是在我加载设备的计算机上找不到接口。例如:
Endpoint anEndpoint = Endpoint.publish("http://localhost:8080/HelloWorldImpl", new HelloWorldImpl());
但是找不到HelloWorldImpl实现的接口。
其他课程是
package application;
@WebService
public interface IHelloWorld{
@WebMethod
public void speak();
}
实施是:
package application;
@WebService(EndpointInterface="application.IHelloWorld")
public class HelloWorldImpl extends ClassForDeviceInteraction implements IHelloWorld{
@Override
public void speak(){
//code that prints to a controller on the device
}
public void initialize(){
//code that initializes stuff for the device
Endpoint anEndpoint = Endpoint.publish("http://localhost:8080/
HelloWorldImpl", new HelloWorldImpl());
}
public static void main(String [] args){
//code to initialize the device
}
}
它在我的计算机上编译得很好,但当我把它放在设备上时,我收到一条错误,指出无法找到接口IHelloWorld
。我无法在Stack Overflow上找到类似的东西。
可能是错误的原因是什么?有没有办法在我传递到端点的类中声明接口,然后在“EndpointInterface”字段中引用它?