<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    athrunwang

    紀(jì)元
    數(shù)據(jù)加載中……
    簡(jiǎn)單的基于CXF框架發(fā)布webserivce服務(wù)
    前段時(shí)間在弄各種框架下的webservice,要弄demo,網(wǎng)上搜羅了許多,都講得很好,但感覺(jué)就是說(shuō)得很多很復(fù)雜,我就想弄個(gè)服務(wù)出來(lái)供我用一下, 要像網(wǎng)上那么做覺(jué)著太麻煩,后來(lái)參考各路神仙大佬們后,把代碼極度縮小,寫了個(gè)小實(shí)例供自個(gè)跑著玩,順便代碼貼上,供大伙口水
    支持包:cxf框架lib下核心包,自己官網(wǎng)上下去,在這里就不貼了,除此之外有java環(huán)境1.6+就Ok了,其它略過(guò),上代碼了。
    package com.cxf.bean;

    public class Employee {
        private String id;
        private String name;
        private String address;

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

    }
    package com.cxf.service;

    import javax.jws.WebService;

    import com.cxf.bean.Employee;

    @WebService
    public interface EmployeeService {
        public boolean insertEmployee(Employee e);

        public boolean updateEmployee(String id);

        public boolean deleteEmployee(String id);

        public Employee seletctEmployee(String id);
    }
    package com.cxf.service;

    import javax.jws.WebService;

    import com.cxf.bean.Employee;

    @WebService
    public class EmployeeServiceImpl implements EmployeeService {

        @Override
        public boolean insertEmployee(Employee e) {
            //業(yè)務(wù)想咋整自已實(shí)現(xiàn)去吧,我這里作例子,就直接回true了,呵呵
            return true;
        }

        @Override
        public boolean updateEmployee(String id) {
            //業(yè)務(wù)想咋整自已實(shí)現(xiàn)去吧,我這里作例子,就直接回true了,呵呵
            return true;
        }

        @Override
        public boolean deleteEmployee(String id) {
            //業(yè)務(wù)想咋整自已實(shí)現(xiàn)去吧,我這里作例子,就直接回true了,呵呵
            return true;
        }

        @Override
        public Employee seletctEmployee(String id) {
            Employee e = new Employee();
            e.setAddress("http://業(yè)務(wù)想咋整自已實(shí)現(xiàn)去吧,我這里作例子,就直接回true了,呵呵");
            e.setId("http://業(yè)務(wù)想咋整自已實(shí)現(xiàn)去吧,我這里作例子,就直接回true了,呵呵");
            e.setName("http://業(yè)務(wù)想咋整自已實(shí)現(xiàn)去吧,我這里作例子,就直接回true了,呵呵");
            return e;
        }

    }
    package test;
    import org.apache.cxf.endpoint.Server;
    import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
    import com.cxf.service.EmployeeServiceImpl;
    public class MainServer {
        public static void main(String[] args) {         
            JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
            factory.setServiceClass(EmployeeServiceImpl.class);
            factory.setAddress("http://192.9.11.53:8088/employeeService");         
            Server server = factory.create();
            server.start();
        }
    }
    package test;

    import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;

    import com.cxf.bean.Employee;
    import com.cxf.service.EmployeeService;

    public class EmployeeServiceClient {
        public static void main(String[] args) {
            JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
            factory.setAddress("http://192.9.11.53:8088/employeeService");
            factory.setServiceClass(EmployeeService.class);
            EmployeeService es = (EmployeeService) factory.create();
            Employee e = new Employee();
            e= es.seletctEmployee("id");
            System.out.println("地址:"+e.getAddress()+"         姓名:"+e.getName()+"         編號(hào):"+e.getId());
            System.out.println(es.seletctEmployee("test"));
        }
    }
    //在eclipse里跑發(fā)布類后瀏覽器中訪問(wèn)http://192.9.11.53:8088/employeeService?wsdl得到描述wsdl
    <wsdl:definitions name="EmployeeServiceImplService" targetNamespace="http://service.cxf.com/"><wsdl:types><xs:schema elementFormDefault="unqualified" targetNamespace="http://service.cxf.com/" version="1.0"><xs:element name="deleteEmployee" type="tns:deleteEmployee"/><xs:element name="deleteEmployeeResponse" type="tns:deleteEmployeeResponse"/><xs:element name="insertEmployee" type="tns:insertEmployee"/><xs:element name="insertEmployeeResponse" type="tns:insertEmployeeResponse"/><xs:element name="seletctEmployee" type="tns:seletctEmployee"/><xs:element name="seletctEmployeeResponse" type="tns:seletctEmployeeResponse"/><xs:element name="updateEmployee" type="tns:updateEmployee"/><xs:element name="updateEmployeeResponse" type="tns:updateEmployeeResponse"/><xs:complexType name="updateEmployee"><xs:sequence><xs:element minOccurs="0" name="arg0" type="xs:string"/></xs:sequence></xs:complexType><xs:complexType name="updateEmployeeResponse"><xs:sequence><xs:element name="return" type="xs:boolean"/></xs:sequence></xs:complexType><xs:complexType name="insertEmployee"><xs:sequence><xs:element minOccurs="0" name="arg0" type="tns:employee"/></xs:sequence></xs:complexType><xs:complexType name="employee"><xs:sequence><xs:element minOccurs="0" name="address" type="xs:string"/><xs:element minOccurs="0" name="id" type="xs:string"/><xs:element minOccurs="0" name="name" type="xs:string"/></xs:sequence></xs:complexType><xs:complexType name="insertEmployeeResponse"><xs:sequence><xs:element name="return" type="xs:boolean"/></xs:sequence></xs:complexType><xs:complexType name="deleteEmployee"><xs:sequence><xs:element minOccurs="0" name="arg0" type="xs:string"/></xs:sequence></xs:complexType><xs:complexType name="deleteEmployeeResponse"><xs:sequence><xs:element name="return" type="xs:boolean"/></xs:sequence></xs:complexType><xs:complexType name="seletctEmployee"><xs:sequence><xs:element minOccurs="0" name="arg0" type="xs:string"/></xs:sequence></xs:complexType><xs:complexType name="seletctEmployeeResponse"><xs:sequence><xs:element minOccurs="0" name="return" type="tns:employee"/></xs:sequence></xs:complexType></xs:schema></wsdl:types><wsdl:message name="insertEmployeeResponse"><wsdl:part element="tns:insertEmployeeResponse" name="parameters">
        </wsdl:part></wsdl:message><wsdl:message name="updateEmployee"><wsdl:part element="tns:updateEmployee" name="parameters">
        </wsdl:part></wsdl:message><wsdl:message name="insertEmployee"><wsdl:part element="tns:insertEmployee" name="parameters">
        </wsdl:part></wsdl:message><wsdl:message name="updateEmployeeResponse"><wsdl:part element="tns:updateEmployeeResponse" name="parameters">
        </wsdl:part></wsdl:message><wsdl:message name="deleteEmployeeResponse"><wsdl:part element="tns:deleteEmployeeResponse" name="parameters">
        </wsdl:part></wsdl:message><wsdl:message name="seletctEmployee"><wsdl:part element="tns:seletctEmployee" name="parameters">
        </wsdl:part></wsdl:message><wsdl:message name="seletctEmployeeResponse"><wsdl:part element="tns:seletctEmployeeResponse" name="parameters">
        </wsdl:part></wsdl:message><wsdl:message name="deleteEmployee"><wsdl:part element="tns:deleteEmployee" name="parameters">
        </wsdl:part></wsdl:message><wsdl:portType name="EmployeeService"><wsdl:operation name="updateEmployee"><wsdl:input message="tns:updateEmployee" name="updateEmployee">
        </wsdl:input><wsdl:output message="tns:updateEmployeeResponse" name="updateEmployeeResponse">
        </wsdl:output></wsdl:operation><wsdl:operation name="insertEmployee"><wsdl:input message="tns:insertEmployee" name="insertEmployee">
        </wsdl:input><wsdl:output message="tns:insertEmployeeResponse" name="insertEmployeeResponse">
        </wsdl:output></wsdl:operation><wsdl:operation name="deleteEmployee"><wsdl:input message="tns:deleteEmployee" name="deleteEmployee">
        </wsdl:input><wsdl:output message="tns:deleteEmployeeResponse" name="deleteEmployeeResponse">
        </wsdl:output></wsdl:operation><wsdl:operation name="seletctEmployee"><wsdl:input message="tns:seletctEmployee" name="seletctEmployee">
        </wsdl:input><wsdl:output message="tns:seletctEmployeeResponse" name="seletctEmployeeResponse">
        </wsdl:output></wsdl:operation></wsdl:portType><wsdl:binding name="EmployeeServiceImplServiceSoapBinding" type="tns:EmployeeService"><soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="insertEmployee"><soap:operation soapAction="" style="document"/><wsdl:input name="insertEmployee"><soap:body use="literal"/></wsdl:input><wsdl:output name="insertEmployeeResponse"><soap:body use="literal"/></wsdl:output></wsdl:operation><wsdl:operation name="updateEmployee"><soap:operation soapAction="" style="document"/><wsdl:input name="updateEmployee"><soap:body use="literal"/></wsdl:input><wsdl:output name="updateEmployeeResponse"><soap:body use="literal"/></wsdl:output></wsdl:operation><wsdl:operation name="deleteEmployee"><soap:operation soapAction="" style="document"/><wsdl:input name="deleteEmployee"><soap:body use="literal"/></wsdl:input><wsdl:output name="deleteEmployeeResponse"><soap:body use="literal"/></wsdl:output></wsdl:operation><wsdl:operation name="seletctEmployee"><soap:operation soapAction="" style="document"/><wsdl:input name="seletctEmployee"><soap:body use="literal"/></wsdl:input><wsdl:output name="seletctEmployeeResponse"><soap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="EmployeeServiceImplService"><wsdl:port binding="tns:EmployeeServiceImplServiceSoapBinding" name="EmployeeServiceImplPort"><soap:address location="http://192.9.11.53:8088/employeeService"/></wsdl:port></wsdl:service></wsdl:definitions>

    posted on 2011-12-28 20:54 AthrunWang 閱讀(766) 評(píng)論(0)  編輯  收藏


    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 国产一级淫片免费播放| 久久亚洲国产欧洲精品一| 亚美影视免费在线观看| 亚洲一卡2卡三卡4卡有限公司| 黄在线观看www免费看| 好爽好紧好大的免费视频国产| 一级毛片免费视频网站| 亚洲欧洲久久精品| 亚洲高清成人一区二区三区| 每天更新的免费av片在线观看| 国产99久久亚洲综合精品| 亚洲区小说区激情区图片区| 久久不见久久见中文字幕免费| 亚洲国产精品成人综合色在线婷婷| 日本免费的一级v一片| 国产精品免费高清在线观看| 亚洲国产成人精品无码区花野真一| 亚洲区小说区激情区图片区| 国产成人高清精品免费鸭子| 久久国产乱子伦免费精品| 四虎一区二区成人免费影院网址 | 亚洲人成图片小说网站| 99re热免费精品视频观看| 中文字幕免费在线看线人动作大片| 亚洲AV无码乱码麻豆精品国产| 亚洲人成无码网站久久99热国产| 日韩在线视频免费| 亚洲AV无码乱码在线观看代蜜桃| 亚洲中文字幕在线观看| 国产免费小视频在线观看| 免费成人激情视频| 欧洲人免费视频网站在线| 丰满妇女做a级毛片免费观看| 亚洲狠狠婷婷综合久久| 亚洲免费福利视频| 在线电影你懂的亚洲| 亚洲五月综合缴情在线观看| 亚洲成年人啊啊aa在线观看| 精品国产免费观看久久久| 一级A毛片免费观看久久精品| 中国亚洲呦女专区|