• 系统开发系列 之MyEclipse创建WebService详细教程和调用教程(spring框架+maven+CXF框架)


    1 回顾
    【系统开发系列 之MyEclipse创建WebService详细教程和调用教程】介绍了使用JWS实现WebService接口的发布和调用,主要涉及的点有:
    (1)MyEclipse点击File->New->Web services project,选择JAX-WS 版本为2.0;
    (2)添加相应的JAX-WSLibrary,右键项目->properties->JavaBuildPath->Libraries,搜索JAX选择确认,右键项目->properties->JavaBuildPath->Libraries如下如图,点击选中JAX-WS Library在点击Edit,将JAX-WS Library另外两个包添加进去;
    (3)添加对应的业务主类并利用tomcat发布接口。
    详细内容可参考:https://blog.csdn.net/Zmj_Dns/article/details/104435559 MyEclipse创建WebService最详细(避坑)教程

    2 使用spring框架+maven+CXF框架实现
    (1)介绍CXF框架
    CXF可以用来构建和开发 WebService,这些服务可以支持多种协议,比如:SOAP、POST/HTTP、HTTP ,CXF 大大简化了WebService并且可以天然地和 Spring 进行无缝集成。
    SOAP:HTTP 协议 + XML 数据格式
    WSDL:WebService Description Language基于Xml语言,用来描述WebService 以及其函数、参数和返回值
    (2)操作步骤【亲测实现 + 详细步骤,整合了许多资料,避坑手册】
    Step1:运行用spring框架搭建maven web项目
    MyEclipse中选择File —> New —> Other —> Maven Project —> webapp:
    在这里插入图片描述
    设置group id和artifact id —> 点击finish
    在resource目录下创建一个spring.xml的配置文件 —> 去spring的官网找到spring框架的文档,将IOC容器的配置文件的格式拷贝到自己刚刚创建的spring.xml中,参考样例为:

      
    <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"  
       xmlns:jaxws="http://cxf.apache.org/jaxws" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
                        http://www.springframework.org/schema/context   
                        http://www.springframework.org/schema/context/spring-context-3.0.xsd
                        http://cxf.apache.org/jaxws  
                        http://cxf.apache.org/schemas/jaxws.xsd">  
      
    beans>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    Step2:使用POM的方式引入依赖

    
    <dependency>
        <groupId>org.apache.cxfgroupId>
        <artifactId>cxf-rt-frontend-jaxwsartifactId>
        <version>3.1.9version>
    dependency>
    <dependency>
        <groupId>org.apache.cxfgroupId>
        <artifactId>cxf-rt-transports-http-jettyartifactId>
        <v
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
  • 相关阅读:
    leetcode 464. 我能赢吗 官方代码的一步步演进
    我对于测试团队建设的意见
    【QML】使用Qt Design Studio创建时间线动画
    requests.sessions.Session() 和 requests.Session()是相同的
    【日拱一卒行而不辍20220919】自制操作系统
    C++类与对象(3)—拷贝构造函数&运算符重载
    水泥设备如何实现物联网远程监控?
    动态 | 11月数据安全重要政策法规、文件汇总
    认真研究MySQL主从复制
    Java版的数据结构——栈和队列
  • 原文地址:https://blog.csdn.net/langxiaolin/article/details/127712552