可不可以利用URL路径去访问webservice接口呢?

可不可以利用URL路径去访问webservice接口呢?

问题描述:

我想在手机端利用URL访问服务器上的java程序里的webservice接口,应该怎么做呢?请求大神指点。。

手机端是什么语言写的。 基于soap ,http 都可以实现你的需求。 

可以使用restful service来构建webservice接口。参考:http://blog.csdn.net/zztfj/article/details/7609347

如果使用http协议来访问的话,去百度上搜索下restfu service的相关资料;如果是php作为接口开发语言,可以通过使用一些开源框架来实现路由和restful,如:frontcontroller、slim、thinkphp等;如果是使用python作为接口开发语言,可以使用tarmado作为接口服务器,具体的百度下吧,一句两句也说不清楚。

restful ws

这个问题我已经解决了。代码如下:
public class Demo {
public static void main(String args[]){
Client client;
try {
client = new Client(new URL("http://localhost:7003/interfWeb/services/demoInterface?wsdl"));
Object[] results = client.invoke("demo", new Object[] {"hello"});
System.out.println(results[0]);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Demo是接口中的方法,hello是参数。