日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

java - springmvc整合cxf发布webservice

發布時間:2023/12/10 c/c++ 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java - springmvc整合cxf发布webservice 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.jar包已上傳百度云盤,在jar包目錄下

2.web.xml配置

<web-app

  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

  xmlns="http://java.sun.com/xml/ns/javaee"

  xsi:schemaLocation="

    http://java.sun.com/xml/ns/javaee

    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/application/applicationContext-*.xml</param-value>
  </context-param>
  <servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>springmvc</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <servlet>
    <servlet-name>CXFServlet</servlet-name>
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>CXFServlet</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>
</web-app>

2.WEB-INF新建springmvc-servlet.xml? (由于web.xml沒有配置該xml路徑和地址,所以名字不能改,位置放到這里就行)

  配置內容如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:mvc="http://www.springframework.org/schema/mvc"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:tx="http://www.springframework.org/schema/tx"
  xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-4.1.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/beans/spring-beans-4.1.xsd ">

  <!-- 啟動注解驅動-->
  <mvc:annotation-driven/>
  <!-- 啟動包掃描功能,你的代碼-->
  <context:component-scan base-package="com.cxf.*" />
</beans>

3.src目錄,包名一定要com.cxf.*,因為springmvc-servlet.xml配置自動掃描的這個。

com.cxf.service.imp就是你要發布的webservice。

先說一下com.cxf.service實現類代碼注意點:

上面注解不要漏就行了;

?

com.cxf.service.imp代碼注意點:

第一個紅線是接口路徑。

第二個紅線隨便取名,但是不能不取名。發布后,在wsdl上會看看這個。

4.WEB-INF下新建目錄和文件? ?application/applicationContext-cxf.xml,文件名和路徑就是這個,不準改。因為web.xml這樣配置的。哈哈哈。(其實applicationContext-cxf.xml的名字可以小改,自己理解吧)

內容:

<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
  http://cxf.apache.org/jaxws
  http://cxf.apache.org/schemas/jaxws.xsd">

  <!-- cxf3.0及以上版本不需要再手工引入
  <import resource="classpath:META-INF/cxf/cxf.xml" />
  <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
  <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> -->

  <!-- webservice服務l,implementor對應的是實現類,address,是訪問的名字-->
  <jaxws:endpoint id="HelloWorld" implementor="com.cxf.service.imp.SB_SOA_SOA_ImportOrgBpelInfoSrv" address="/org" />

  <!--啟動后,訪問:http://localhost:8080/ws/org?wsdl 會出現xml那就ok了。ws是我項目名字-->
  <!--<jaxws:endpoint id="HelloWorld2" implementor="com.cxf.service.imp.SB_SOA_SOA_ImportEmpBpelInfoSrv" address="/emp" />-->

  <!--啟動后,訪問:http://localhost:8080/ws/emp?wsdl 會出現xml那就ok了。ws是我項目名字-->
</beans>

?

轉載于:https://www.cnblogs.com/sss-justdDoIt/p/9300210.html

總結

以上是生活随笔為你收集整理的java - springmvc整合cxf发布webservice的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。