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

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

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

    使用spring-ws進(jìn)行webservice服務(wù)器端的開(kāi)發(fā)

    Spring Web Services offer another endpoint with which you can aggregate multiple handling into one
    controller, thus grouping functionality together. This model is based on annotations, so you can use it only with
    Java 5 and higher. Here is an example that uses the same marshalled objects as above:
    package samples;
    import org.springframework.ws.server.endpoint.annotation.Endpoint;
    import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
    @Endpoint
    public class AnnotationOrderEndpoint {
        private final OrderService orderService;
        public AnnotationOrderEndpoint(OrderService orderService) {
        this.orderService = orderService;
        }
        @PayloadRoot(localPart = "orderRequest", namespace = "http://samples")
        public Order getOrder(OrderRequest orderRequest) {
        return orderService.getOrder(orderRequest.getId());
        }
        @PayloadRoot(localPart = "order", namespace = "http://samples")
        public void order(Order order) {
        orderService.createOrder(order);
        }
    }
    By annotating the class with @Endpoint, you mark it as a Spring-WS endpoint. Because the endpoint class can
    have multiple request handling methods, we need to instruct Spring-WS which method to invoke for which
    request. This is done using the @PayloadRoot annotation: the getOrder method will be invoked for requests
    with a orderRequest local name and a http://samples namespace URI; the order method for requests with a
    order local name. For more information about these annotations, refer to Section 5.4.3,
    “MethodEndpointMapping”.


     

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

     <description>
      This web application context contains Spring-WS beans. The beans
      defined in this context are automatically detected by Spring-WS,
      similar to the way Controllers are picked up in Spring Web MVC.
     </description>

     <bean
      class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
      <description>
       Detects @PayloadRoot annotations on @Endpoint bean methods.
       The MarshallingAirlineEndpoint has such annotations. It uses
       two interceptors: one that logs the message payload, and the
       other validates it accoring to the 'airline.xsd' schema
       file.
      </description>
     </bean>
     <bean id="echo"
      class="org.springframework.ws.wsdl.wsdl11.DynamicWsdl11Definition">
      <description>
       This bean definition represents a WSDL definition that is
       generated at runtime, based on the builder defined below. It
       can be retrieved by going to /echo/echo.wsdl (i.e. the bean
       name corresponds to the filename).
      </description>
      <property name="builder">
       <description>
        The builder creates a WSDL from the 'echo.xsd' schema.
        It detects all elements that ends with 'Request', finds
        corresponding 'Response' messages, and creates an
        operation based on that. All operations are put in a
        portType with name 'Echo', and binding and service are
        created.
       </description>
       <bean
        class="org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder">
        <property name="schema" value="/WEB-INF/echo.xsd" />
        <property name="portTypeName" value="Echo" />
        <property name="locationUri"
         value="http://localhost:8080/echoweb/services" />
       </bean>
      </property>
     </bean>
     <bean id="echoEndpoint" class="com.vanad.EchoEndpoint">
      <description>This endpoint handles echo requests.</description>
      <property name="echoService" ref="echoService" />
     </bean>
     <bean id="echoService" class="com.vanad.EchoServiceImpl">
      <description>This bean is our "business" service.</description>
     </bean>

     <bean id="payloadLoggingInterceptor"
      class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor">
     </bean>

     <bean id="soapEnvelopeLoggingInterceptor"
      class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor">
     </bean>
     <bean
      class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
      <constructor-arg ref="marshaller" />
     </bean>
     <bean id="marshaller"
      class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
      <property name="contextPath" value="com.vanad.schema" />
     </bean>
    </beans>


     

    也就是說(shuō)用spring開(kāi)發(fā)webservice需要配置一下文件:
    1.EndPoint,如果使用標(biāo)記的話,就可以不用繼承任何類(lèi)
    2.EndpointMapping,Detects @PayloadRoot annotations on @Endpoint bean methods.
    3.DynamicWsdl11Definition。動(dòng)態(tài)生成WSDL
    如果使用JAXB作為Object和XML的映射,那么還需要
    4.Marshaller一般為Jaxb2Marshaller
    5.如果是使用的標(biāo)記的話,還需要MarshallingMethodEndpointAdapter,一般現(xiàn)在使用
        GenericMarshallingMethodEndpointAdapter

    posted on 2007-12-25 17:48 劉錚 閱讀(6190) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): WebService

    <2025年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    導(dǎo)航

    統(tǒng)計(jì)

    留言簿(1)

    文章分類(lèi)(141)

    文章檔案(147)

    搜索

    最新評(píng)論

    主站蜘蛛池模板: 一二三四在线观看免费中文在线观看 | 亚洲免费在线观看| 曰批免费视频播放在线看片二| 中国亚洲呦女专区| 亚洲中文精品久久久久久不卡| 免费精品国自产拍在线播放 | 毛片无码免费无码播放| 手机看黄av免费网址| 日本免费网站观看| 亚洲男人第一av网站| 亚洲人成77777在线播放网站不卡| 国产人成免费视频网站| 亚洲国产成人久久综合野外| 在线观看亚洲AV日韩AV| 亚洲日本中文字幕天天更新| 亚洲国产午夜精品理论片| 亚洲av无码不卡| 久久国产乱子免费精品| 亚洲精品精华液一区二区 | 国产成人免费福利网站| 日本一区二区在线免费观看| 羞羞视频免费网站在线看| 亚洲精品电影在线| 白白国产永久免费视频| 日本高清在线免费| 亚洲av日韩精品久久久久久a| 国内精品免费麻豆网站91麻豆 | 亚洲老熟女五十路老熟女bbw| 国产免费卡一卡三卡乱码| 亚洲黄色一级毛片| 成在线人视频免费视频| 超pen个人视频国产免费观看| 免费看美女午夜大片| 亚洲国产国产综合一区首页| 四虎永久在线精品免费网址 | 一级做a爰全过程免费视频毛片| 高清国语自产拍免费视频国产| 免费人成又黄又爽的视频在线电影| 亚洲夜夜欢A∨一区二区三区 | 亚洲精品久久久久无码AV片软件| 亚洲人成网站色在线入口|