zoukankan      html  css  js  c++  java
  • spring 发布 Jax-Ws Service (一)

    1、maven依赖:

    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core</artifactId>
        <version>2.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.jdom</groupId>
        <artifactId>jdom</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>jaxen</groupId>
        <artifactId>jaxen</artifactId>
        <version>1.1.6</version>
    </dependency>

    2、编写需要发布的JavaBean

    import javax.jws.WebMethod;
    import javax.jws.WebService;
    
    import org.springframework.stereotype.Component;
    
    @Component
    @WebService(serviceName = "myService")
    public class HolidayEndpoint {
    
        @WebMethod
        public String say(String name) {
            return "hello,"+name;
        }
    
    }

    3、配置 web.xml:

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:beans.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    4、Spring的配置文件beans.xml

    <bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter">  
        <property name="baseAddress" value="http://localhost:8081/services/"/>  
    </bean>

    服务器:tomcat 端口号:8081
    wsdl:http://localhost:8081/services/myService?wsdl

    说明及注意

    (1)、通过http://localhost:8081/services/myService?wsdl 访问webservice部署描述符 
    还有自动生成的xsd:http://localhost:8081/services/myService?xsd=1 。
    (2)、@SOAPBinding(parameterStyle=ParameterStyle.WRAPPED)
    必须添加,否则会报错;另外,如果发布的方法只有一个参数可以使用@SOAPBinding(parameterStyle=ParameterStyle.BARE)。
    (3)、@WebService(serviceName = "myService") 服务名称与Spring配置的bean一致。
    (4)、webservice的端口设置不要与服务器一样,这一点非常重要否则服务器应用与webservice服务冲突会产生HTTP404错误。

  • 相关阅读:
    Zero-shot Relation Classification as Textual Entailment (Abiola Obamuyide, Andreas Vlachos, 2018)阅读笔记:Model
    高阶Erlang:超大只的问答房间
    高阶的Parser:可变运算优先级
    Erlang练习2:火烈鸟
    Erlang实现的模拟kaboose(山寨kahoot)
    Prolog模拟社交圈
    08-bootcss
    07-jQuery
    06-字符串、表单form、input标签
    05-有名/无名函数
  • 原文地址:https://www.cnblogs.com/rinack/p/7903759.html
Copyright © 2011-2022 走看看