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

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

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

    使用spring-ws進行webservice服務器端的開發

    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>


     

    也就是說用spring開發webservice需要配置一下文件:
    1.EndPoint,如果使用標記的話,就可以不用繼承任何類
    2.EndpointMapping,Detects @PayloadRoot annotations on @Endpoint bean methods.
    3.DynamicWsdl11Definition。動態生成WSDL
    如果使用JAXB作為Object和XML的映射,那么還需要
    4.Marshaller一般為Jaxb2Marshaller
    5.如果是使用的標記的話,還需要MarshallingMethodEndpointAdapter,一般現在使用
        GenericMarshallingMethodEndpointAdapter

    posted on 2007-12-25 17:48 劉錚 閱讀(6184) 評論(0)  編輯  收藏 所屬分類: WebService

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    導航

    統計

    留言簿(1)

    文章分類(141)

    文章檔案(147)

    搜索

    最新評論

    主站蜘蛛池模板: 国产高清免费在线| 免费看国产成年无码AV片| 亚洲精品第一国产综合精品99 | 亚洲精品V欧洲精品V日韩精品| 国产精品日本亚洲777| 免费黄色网址入口| 亚洲AV无码一区二区乱子仑| 成人免费看吃奶视频网站| 日韩亚洲国产高清免费视频| 好男人看视频免费2019中文| 亚洲欧美熟妇综合久久久久| 尤物永久免费AV无码网站| 黄色一级毛片免费看| 中文字幕亚洲图片| 免费国产污网站在线观看15| 亚洲人成网站18禁止久久影院 | 国产精品久久久亚洲| 99精品在线免费观看| 亚洲乱码一二三四区国产| 天天操夜夜操免费视频| 特级毛片全部免费播放a一级| 亚洲伊人久久综合影院| 日韩免费无码一区二区三区 | 亚洲国产高清在线一区二区三区| 成在线人直播免费视频| 亚洲AV无码一区二区三区DV| 69成人免费视频| 老司机午夜性生免费福利| 国产AV无码专区亚洲AVJULIA| 亚洲三级高清免费| selaoban在线视频免费精品| 91在线精品亚洲一区二区| 色视频色露露永久免费观看| WWW免费视频在线观看播放| 亚洲国产成人超福利久久精品| 国产特级淫片免费看| 久章草在线精品视频免费观看| 亚洲无mate20pro麻豆| 国产成人综合亚洲AV第一页 | 免费国产作爱视频网站| 粉色视频成年免费人15次|