<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)  編輯  收藏


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


    網站導航:
     
    主站蜘蛛池模板: 激情综合色五月丁香六月亚洲| 成人免费毛片视频| 久久精品国产亚洲Aⅴ香蕉| 日韩色视频一区二区三区亚洲| 无码高潮少妇毛多水多水免费 | 亚洲成a人片在线观看久| 亚洲大尺度无码无码专线一区| 大学生高清一级毛片免费| 亚洲中文字幕无码亚洲成A人片| 中文字幕无码视频手机免费看| 亚洲 日韩经典 中文字幕| 日本a级片免费看| 一级A毛片免费观看久久精品| 亚洲日韩v无码中文字幕| 久久福利青草精品资源站免费| 亚洲国产成人久久综合一| 四虎在线免费视频| 亚洲另类无码专区首页| 免费人成视频在线观看不卡| 男女一进一出抽搐免费视频| 亚洲成在人线av| 久久久久免费看黄A片APP| 国产精品亚洲va在线观看| 亚洲精品无码激情AV| 国产99视频精品免费专区| 国产成人精品日本亚洲11| 免费一级毛片在线观看| 中文精品人人永久免费| 亚洲一区免费在线观看| 国产乱子伦精品免费女| 中国好声音第二季免费播放| 亚洲国产精品成人精品小说| 日韩成人免费在线| 国内精品久久久久影院免费| 中文字幕无码亚洲欧洲日韩| 亚洲一区二区三区在线视频 | 精品国产免费观看一区| 精品免费久久久久国产一区 | 浮力影院亚洲国产第一页| 五月亭亭免费高清在线| 国产亚洲视频在线观看网址|