webservice

入门(内容比较齐全):http://blog.csdn.net/qq32933432/article/details/51394749

 1.解释:http://blog.csdn.net/qq32933432/article/details/51394749

SOAP:Simple Object Access Protocol 简单对象访问协议

WSDL:Web Services Description Language:跟java一样,也是一种语言,是通过xml的形式说明该webservice如何调用。相当于一个使用说明书。

Axis:并不完全是SOAP引擎,还提供创建服务名,客户端和网关SOAP操作的基本框架。

如何访问wsdl文件:通过在webservice的url后面加?wsdl的方式。如:http://localhost:8088/RPCDemo/function?wsdl

发布:Endpoint.publish("http://127.0.0.1:8080/sayHello", new SayHellowIntefaceImpl());

wsdl文件标签解释:https://wenku.baidu.com/view/f8a4fe0c90c69ec3d5bb7527.html

stop:停止服务。

其他注意事项:
1) 给类添加上@WebService注解后,类中所有的非静态方法都将会对外公布。不支持静态方法,final方法。
2) 如果希望某个方法(非static,非final)不对外公开,可以在方法上添加@WebMethod(exclude=true),阻止对外公开。
3) 如果一个类上,被添加了@WebService注解,则必须此类至少有一个可以公开的方法,否则将会启动失败。
4) 服务类中不能没有方法
5) @WebMethod(exclude=true)屏蔽方法

2.注解:

http://blog.csdn.net/gjb724332682/article/details/46324661

@WebService:此注示用来标明此java类为某个WebService的实现类或者标明此java接口定义了某个WebService的接口

@XmlSeeAlso:派生子类类以及根据接口参数识别出的类实现多态性

3.简单工程:

https://www.cnblogs.com/AlanLee/archive/2017/06/02/6933073.html

步骤:

程序结果如下:

(1)服务端代码:

    public String transWords(String words){
        String res = "";
        for(char ch : words.toCharArray()){
            res += ch + ",";
        }
        return res;
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Endpoint.publish("http://localhost:8088/RPCDemo/function", new Function());
        System.out.println("Publish Success");
    }
View Code

(2)客户端代码:

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Function fu;
        try {
            fu = new FunctionServiceLocator().getFunctionPort();
            String or = "I want to eat ege!";
            System.out.println("远程调用处理前数据为:"+or);
            String str = fu.transWords(or);
            System.out.println("远程调用处理后数据为:"+str);
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ServiceException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
View Code

运行:

运行服务端的main,再运行客户端的main就可以看到结果:

报错处理: The Tomcat v6.0 Server server does not support the client project RPCClient.

若在自动生成客户端代码时报错,是因为不支持。

处理过程如下:http://www.cnblogs.com/HZDX-2017/p/7229843.html

 

4,开发:axis,cxf

(1)axis框架:

即时发送:有源码,将源码*.java改名为*.jws(jws:java web service),部署到····\webapps\axis(文件放到webroot)

定制发送:没有源码,只有.class文件,需要*.wsdd(wsdd:web service deployment descriptor)文件,客户端管理工具

开发实例:http://blog.csdn.net/xw13106209/article/details/7049614/

--- 比较详细:http://nopainnogain.iteye.com/blog/791525

----- 建web项目:https://jingyan.baidu.com/article/ce436649f3334e3773afd3e0.html

 

posted on 2017-11-23 09:27  活在当下L  阅读(132)  评论(0编辑  收藏  举报

导航