我正试图在两个android设备之间建立基本的恒河通信。
发送消息的客户端 AsyncTask
public class AsyncHessian extends AsyncTask<String,String,String> {
@Override
protected String doInBackground(String... params) {
String url = "http://192.168.1.37:8080/test/test";
try{
HessianProxyFactory factory = new HessianProxyFactory();
TService basic = (TService) factory.create(TService.class, url);
basic.hello();
Log.i("Hello", "Hessian!");
}
catch(Exception e){e.printStackTrace();}
return "";
}}
服务器接口的端实现
public class TServiceImpl extends HessianServlet implements TService{
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
Context context = new Context(server, "/", Context.SESSIONS);
context.addServlet(TServiceImpl.class, "/test");
server.start();
}
public void hello() {
System.out.println("Hello Hessian!");
}}
接口
public interface TService {
public void hello();}
服务器在Android设备上的jetty上运行。消息正在从应用程序发送到服务器。
我肯定消息到达目的地,因为当jetty停止时,我得到了一个ECONNREFUSED错误。当它开着的时候,我给它取了个标题。
发布于 2016-04-12 13:29:16
在web.xml中配置servlet
<servlet>
<servlet-name>testService</servlet-name>
<servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class>
<init-param>
<param-name>home-class</param-name>
<param-value>TServiceImpl's full name</param-value>
</init-param>
<init-param>
<param-name>home-api</param-name>
<param-value>TService's full name</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>testService</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>请参阅:http://hessian.caucho.com/doc/hessian-overview.xtp#Configurationforstandardweb.xml
发布于 2019-08-08 22:36:38
我也有同样的问题。这可以是很多事情,但“<”是HTML或XML消息的开始标记。
可能的原因:
我们需要更多关于程序配置的详细信息。
https://stackoverflow.com/questions/18397095
复制相似问题