Spring-Shiro框架使用说明

2 篇文章 0 订阅
1 篇文章 0 订阅

1.框架集成Webservice

https://www.oschina.net/p/spring-shiro-training 这个项目增加集成Webservice功能,参考 http://blog.csdn.net/hbsong75/article/details/41207585 ,但是修正了以下几点

1.1 pom.xml中添加依赖包

要按照下面的格式,按照上面链接中的方法没有调通

    <!--cxf webservice 集成配置 -->
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxrs</artifactId>
    <version>${cxf.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
    </dependency>

1.2 版本号

版本号注意要填写3.0.3,我用了其他的版本jar包下载不下来

<cxf.version>3.0.3</cxf.version>

1.3 在web.xml文件中添加servlet

<servlet>
    <servlet-name>cxf</servlet-name>
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>cxf</servlet-name>
    <url-pattern>/services/*</url-pattern>
</servlet-mapping>

1.4 spring-cxf.xml

spring目录下spring-cxf.xml文件中的内容这样填写,指明要发布的webservice

   <jaxws:server id="mobileService" address="/mobile">
          <jaxws:serviceBean>
                 <ref bean="mobileServiceImpl"/>
          </jaxws:serviceBean>
   </jaxws:server>

   <bean id="mobileServiceImpl" class="com.wangzhixuan.webservice.impl.MobileServiceImpl"/>

结合前面web.xml指定的路径,则webservice的访问地址为http://localhost:8080/项目名/services/mobile?wsdl
这样还是不能访问,需要在拦截器中把webservice访问放行

1.5 不要让Shiro拦截Webservice

/services = anon <!-- webservice的链接不需要进行认证 -->
/services/** = anon <!-- webservice ws后面的所有链接都不进行认证 -->

spring-shiro.xml文件截图

2.添加JSON包

项目中可能还需要打包和解析JSON数据,maven中增加相关jar包。pom.xml中这样填写

<dependency>
    <groupId>net.sf.json-lib</groupId>
    <artifactId>json-lib</artifactId>
    <version>2.4</version>
    <classifier>jdk15</classifier>
</dependency>

注意:JDK版本要填写jdk15,虽然我的项目用的是JDK7。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值