• WebService第二天——WebService框架CXF


    一、CXF

      1.什么是CXF

      Apache CXF = Celtix + XFire,开始叫 Apache CeltiXfire,后来更名为 Apache CXF 了,以下简称为 CXF。CXF 继承了 Celtix 和 XFire 两大开源项目的精华,提供了对 JAX-WS 全面的支持,并且提供了多种 Binding 、DataBinding、Transport 以及各种 Format 的支持,并且可以根据实际项目的需要,采用代码优先(Code First)或者 WSDL 优先(WSDL First)来轻松地实现 Web Services 的发布和使用。Apache CXF已经是一个正式的Apache顶级项目。

      // 来自百度百科(也就是一个WebService的框架)

      官网:http://cxf.apache.org/index.html

      2.入门案例

      参见:http://www.cnblogs.com/frankliiu-java/articles/1641949.html

        http://blog.csdn.net/accountwcx/article/details/47082487

      下载CXF后可以使用它的命令实现代码的生成以便调用:——实际中基本不会再使用JDK自带的wsimport的命令

        

      当然,官方下载的压缩包中也有例子和文档:

        与spring整合的例子可以结合samples与网友随笔:http://sunny.blog.51cto.com/182601/625540/

        

       使用JQuery调用webService:

    $(function(){
            $("#mybutton").click(function(){
                var data = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://server.web.cxf.rl.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'
                      +'<soapenv:Body>'
                      +'<q0:sayHello>'
                      +'   <arg0>sss</arg0>'
                      +' </q0:sayHello>'
                      +'</soapenv:Body>'
                      +'</soapenv:Envelope>';
                      
                    $.ajax({
                        url:'http://localhost:8080/cxf-web-server/services/hello',
                        type:'post',
                        dataType:'xml',
                        contentType:'text/xml;charset=UTF-8',
                        data:data,
                        success:function(responseText){
                            alert($(responseText).find('return').text());
                        },
                        error:function(){
                            alert("error");
                        }
                    })
            })
        })
    View Code

      这里详细的使用方法,待补充...

  • 相关阅读:
    解决死锁四大方式
    Windows内存管理简介:
    排序算法优劣
    排序
    HTTPs
    http和https的异同
    HTTP协议
    FTP与TFTP
    tomcat热部署
    开发心得体会
  • 原文地址:https://www.cnblogs.com/jiangbei/p/7628959.html
Copyright © 2020-2023  润新知