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

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

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

    athrunwang

    紀元
    數據加載中……
    簡單的基于CXF框架發布webserivce服務
    前段時間在弄各種框架下的webservice,要弄demo,網上搜羅了許多,都講得很好,但感覺就是說得很多很復雜,我就想弄個服務出來供我用一下, 要像網上那么做覺著太麻煩,后來參考各路神仙大佬們后,把代碼極度縮小,寫了個小實例供自個跑著玩,順便代碼貼上,供大伙口水
    支持包:cxf框架lib下核心包,自己官網上下去,在這里就不貼了,除此之外有java環境1.6+就Ok了,其它略過,上代碼了。
    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) {
            //業務想咋整自已實現去吧,我這里作例子,就直接回true了,呵呵
            return true;
        }

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

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

        @Override
        public Employee seletctEmployee(String id) {
            Employee e = new Employee();
            e.setAddress("http://業務想咋整自已實現去吧,我這里作例子,就直接回true了,呵呵");
            e.setId("http://業務想咋整自已實現去吧,我這里作例子,就直接回true了,呵呵");
            e.setName("http://業務想咋整自已實現去吧,我這里作例子,就直接回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()+"         編號:"+e.getId());
            System.out.println(es.seletctEmployee("test"));
        }
    }
    //在eclipse里跑發布類后瀏覽器中訪問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) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲伊人久久精品影院| 噼里啪啦电影在线观看免费高清| 女人张开腿等男人桶免费视频| 久久久久久亚洲Av无码精品专口 | 免费大黄网站在线观| 亚洲av无码成人精品区一本二本| 无码免费午夜福利片在线| 亚洲中文无码永久免费| 免费看片免费播放| 激情小说亚洲色图| a级亚洲片精品久久久久久久| 两性色午夜视频免费网| 亚洲国产精品久久66| 黄色成人免费网站| 亚洲精品国产第一综合99久久| 日本成人在线免费观看| 美女裸免费观看网站| 亚洲情综合五月天| 中文字幕在线免费| 亚洲妇女无套内射精| 亚洲精品国产精品乱码不卞| 免费看少妇高潮成人片| 亚洲毛片基地日韩毛片基地| 性色av无码免费一区二区三区| 亚洲AV无码专区在线厂| 亚洲欧洲国产精品香蕉网| 亚洲无砖砖区免费| 亚洲一卡2卡3卡4卡乱码 在线| 国产精品黄页在线播放免费| aa级女人大片喷水视频免费| 亚洲欧洲日产专区| 四虎AV永久在线精品免费观看| 日韩精品无码免费专区午夜不卡 | 亚洲日韩精品无码专区加勒比| 亚洲精品视频在线看| 最近中文字幕mv免费高清在线| 337p日本欧洲亚洲大胆人人| 亚洲人成在线观看| 免费a级毛片无码av| 91免费播放人人爽人人快乐| eeuss免费影院|