`
dyccsxg
  • 浏览: 205286 次
  • 性别: Icon_minigender_1
  • 来自: 青岛
社区版块
存档分类

CXF 发布Web Service - JaxWsWebServicePublisherBeanPostProcessor

 
阅读更多

这种方式不需要配置<jaxws:endpoint>标签,在spring加载bean时自动将标注为@WebService的类发布为服务。

1. web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="
    http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
    
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    
    <servlet>
        <servlet-name>mvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>mvc</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>
    
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
</web-app>
2. spring.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd" >
    
    <context:annotation-config />
    <import resource="classpath:META-INF/cxf/cxf.xml" />
    
</beans>

3. WEB-INF/mvc-servlet.xml

<?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.xsd">
    
    <bean id="myPasswordCallback" class="org.demo.ws.server.MyPasswordCallback" />
    <bean id="wSS4JInInterceptor" class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
        <constructor-arg>
            <map>
                <entry key="action" value="UsernameToken" />
                <entry key="passwordType" value="PasswordText" />
                <entry key="user" value="cxfServer" />
                <entry key="passwordCallbackRef">
                    <ref bean="myPasswordCallback" />
                </entry>
            </map>
        </constructor-arg>
    </bean>
    <bean id="jaxWsServerFactoryBean" class="org.apache.cxf.jaxws.JaxWsServerFactoryBean" scope="prototype">
        <property name="inInterceptors">
            <list>
                <ref bean="wSS4JInInterceptor"/>
            </list>
        </property>
    </bean>
    <bean id="jaxWsWebServicePublisherBeanPostProcessor" 
          class="org.apache.cxf.jaxws.spring.JaxWsWebServicePublisherBeanPostProcessor">
        <property name="urlPrefix" value="/" />
        <property name="prototypeServerFactoryBeanName" value="jaxWsServerFactoryBean" />
    </bean>
    
    <bean id="helloWorldImpl" class="org.demo.ws.server.HelloWorldImpl" />
    
</beans>
4. 访问 web service

http://localhost:8080/context/services/hello?wsdl

分享到:
评论

相关推荐

    cxf-rt-rs-client-3.0.1-API文档-中文版.zip

    赠送jar包:cxf-rt-rs-client-3.0.1.jar; 赠送原API文档:cxf-rt-rs-client-3.0.1-javadoc.jar; 赠送源代码:cxf-rt-rs-client-3.0.1-sources.jar; 赠送Maven依赖信息文件:cxf-rt-rs-client-3.0.1.pom; 包含...

    cxf-rt-frontend-jaxrs-3.0.1-API文档-中文版.zip

    赠送jar包:cxf-rt-frontend-jaxrs-3.0.1.jar; 赠送原API文档:cxf-rt-frontend-jaxrs-3.0.1-javadoc.jar; 赠送源代码:cxf-rt-frontend-jaxrs-3.0.1-sources.jar; 赠送Maven依赖信息文件:cxf-rt-frontend-jaxrs...

    cxf-rt-transports-http-3.0.1-API文档-中文版.zip

    赠送jar包:cxf-rt-transports-http-3.0.1.jar; 赠送原API文档:cxf-rt-transports-http-3.0.1-javadoc.jar; 赠送源代码:cxf-rt-transports-http-3.0.1-sources.jar; 赠送Maven依赖信息文件:cxf-rt-transports-...

    cxf-rt-frontend-simple-3.0.1-API文档-中文版.zip

    赠送jar包:cxf-rt-frontend-simple-3.0.1.jar; 赠送原API文档:cxf-rt-frontend-simple-3.0.1-javadoc.jar; 赠送源代码:cxf-rt-frontend-simple-3.0.1-sources.jar; 赠送Maven依赖信息文件:cxf-rt-frontend-...

    cxf-rt-frontend-jaxws-3.0.1-API文档-中文版.zip

    赠送jar包:cxf-rt-frontend-jaxws-3.0.1.jar; 赠送原API文档:cxf-rt-frontend-jaxws-3.0.1-javadoc.jar; 赠送源代码:cxf-rt-frontend-jaxws-3.0.1-sources.jar; 赠送Maven依赖信息文件:cxf-rt-frontend-jaxws...

    cxf-rt-databinding-jaxb-3.0.1-API文档-中文版.zip

    赠送jar包:cxf-rt-databinding-jaxb-3.0.1.jar; 赠送原API文档:cxf-rt-databinding-jaxb-3.0.1-javadoc.jar; 赠送源代码:cxf-rt-databinding-jaxb-3.0.1-sources.jar; 赠送Maven依赖信息文件:cxf-rt-...

    cxf-rt-bindings-soap-3.0.1-API文档-中文版.zip

    赠送jar包:cxf-rt-bindings-soap-3.0.1.jar; 赠送原API文档:cxf-rt-bindings-soap-3.0.1-javadoc.jar; 赠送源代码:cxf-rt-bindings-soap-3.0.1-sources.jar; 赠送Maven依赖信息文件:cxf-rt-bindings-soap-...

    cxf-core-3.0.1-API文档-中文版.zip

    赠送jar包:cxf-core-3.0.1.jar; 赠送原API文档:cxf-core-3.0.1-javadoc.jar; 赠送源代码:cxf-core-3.0.1-sources.jar; 赠送Maven依赖信息文件:cxf-core-3.0.1.pom; 包含翻译后的API文档:cxf-core-3.0.1-...

    Apache CXF开发Web Service 理解CXF Frontends之Code-First

    为了测试服务,我们可以创建一个简单的SOAP客户端,或者使用CXF的`cxf-codegen-plugin`生成客户端代理类。 总的来说,Apache CXF的Code-First开发模式使得Web服务的创建变得更加直观和简单,开发者可以直接在Java...

    cxfWebservice客户端全部jar包及极简调用方法.rar

    cxf-core-3.0.0.jar,cxf-rt-bindings-soap-3.0.0.jar,cxf-rt-databinding-jaxb-3.0.0.jar,cxf-rt-frontend-jaxws-3.0.0.jar,cxf-rt-frontend-simple-3.0.0.jar,cxf-rt-transports-http-3.0.0.jar,cxf-rt-...

    cxf框架包 apache-cxf-3.4.3.tar.gz

    在本案例中,我们讨论的是"apache-cxf-3.4.3.tar.gz",这是Apache CXF 3.4.3版本的压缩包,通常包含了CXF框架的所有组件和必要的库文件。 **1. CXF框架介绍** Apache CXF是一个全面的服务开发框架,它的全称是...

    cxf-rt-frontend-jaxws-3.0.16.jar 下载

    cxf-rt-frontend-jaxws-3.0.16.jar jar包下载3.0.16版本下载

    Apache CXF开发Web Service 理解CXF Frontends之Contract-First

    在"Apache CXF开发Web Service理解CXF Frontends之Contract-First"的主题中,我们将深入探讨以下几个关键知识点: 1. **Web服务基础**:Web服务是一种通过网络进行通信的应用程序接口,使用标准协议如SOAP(简单...

    cxf-rt-transports-http-jetty-3.0.2.zip

    综上所述,"cxf-rt-transports-http-jetty-3.0.2.zip"和"jcabi-aspects.zip"分别是Apache CXF框架的一个组件和一个Java注解库,它们都为Java开发者提供了强大的工具,以更高效和灵活的方式构建和管理Web服务及应用...

    cxf-rt-bindings-xml-3.0.1-API文档-中文版.zip

    赠送jar包:cxf-rt-bindings-xml-3.0.1.jar; 赠送原API文档:cxf-rt-bindings-xml-3.0.1-javadoc.jar; 赠送源代码:cxf-rt-bindings-xml-3.0.1-sources.jar; 赠送Maven依赖信息文件:cxf-rt-bindings-xml-3.0.1....

    cxf-rt-ws-addr-3.0.1-API文档-中文版.zip

    赠送jar包:cxf-rt-ws-addr-3.0.1.jar; 赠送原API文档:cxf-rt-ws-addr-3.0.1-javadoc.jar; 赠送源代码:cxf-rt-ws-addr-3.0.1-sources.jar; 赠送Maven依赖信息文件:cxf-rt-ws-addr-3.0.1.pom; 包含翻译后的API...

    apache-cxf-3.1.1跟3.1.6所有jar包

    此外,还有其他如`cxf-rt-bindings-soap.jar`、`cxf-rt-databinding-jaxb.jar`、`cxf-rt-rs-extension-providers.jar`等,它们分别对应于不同的功能,如SOAP绑定、JAXB数据绑定和RESTful服务的提供者扩展。...

    cxf-rt-rs-extension-providers-3.0.1-API文档-中文版.zip

    赠送jar包:cxf-rt-rs-extension-providers-3.0.1.jar; 赠送原API文档:cxf-rt-rs-extension-providers-3.0.1-javadoc.jar; 赠送源代码:cxf-rt-rs-extension-providers-3.0.1-sources.jar; 赠送Maven依赖信息...

    cxf.xml,cxf-servlet.xml,cxf-extension-soap.xml

    &lt;import resource="classpath:META-INF/cxf/cxf.xml"/&gt; &lt;import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/&gt; &lt;import resource="classpath:META-INF/cxf/cxf-servlet.xml"/&gt;

    cxf-dosgi-ri-singlebundle-distribution-1.4.0.jar

    cxf-dosgi-ri-singlebundle-distribution-1.4.0.jar

Global site tag (gtag.js) - Google Analytics