第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

Spring發(fā)布WebService

標簽:
Spring

Maven:

    <!-- WebService --><dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-jaxws</artifactId>
    <version>3.0.4</version></dependency><dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http</artifactId>
    <version>3.0.4</version></dependency><dependency>
    <groupId>org.apache.neethi</groupId>
    <artifactId>neethi</artifactId>
    <version>3.0.3</version></dependency>

这里的org.apache.neethi的版本最好是3.0.3   不然你使用了别人的webservice可能会报错   我试过用3.0.2报错
: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: java.lang.RuntimeException: Cannot create a secure XMLInputFactory
具体原因不清楚

还有记得别加这个

webp


不然还是报错


  Caused by: org.apache.cxf.BusException: No DestinationFactory was found for the namespace http://schemas.xmlsoap.org/soap/http.

webxml:

<servlet>
    <servlet-name>CXFService</servlet-name>
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
    <load-on-startup>1</load-on-startup></servlet><servlet-mapping>
    <servlet-name>CXFService</servlet-name>
    <url-pattern>/ws/*</url-pattern></servlet-mapping>

url-pattern自定义,就是你访问webservice的地址
Springxml:

  <!-- 接口的实现类声明 --><bean id="自定义" class="写你webservice接口的实现类" /><!-- 默认自带日志输出 --><bean id="inMessageInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor" /><bean id="outLoggingInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor" /><!-- 发布WebService --><jaxws:server id="自定义" serviceClass="这里写你接口不是实现类"
    address="/自定义访问webservice的地址">
    <jaxws:serviceBean>
        <ref bean="自定义接口的实现类" />
    </jaxws:serviceBean>
    <jaxws:inInterceptors>
        <ref bean="inMessageInterceptor" />
    </jaxws:inInterceptors>
    <jaxws:outInterceptors>
        <ref bean="outLoggingInterceptor" />
    </jaxws:outInterceptors></jaxws:server>

webservice接口:

package ws.spring.server;  
  
import javax.jws.WebMethod;  
import javax.jws.WebService;  
  
@WebService  public interface UserWS {  
    @WebMethod  
    public UserBean getUserById(int id);  
}

webservice实现类 :

package ws.spring.server;  
  
import javax.jws.WebService;  
  
@WebService  public class UserWSImpl implements UserWS {  
    public UserWSImpl(){  
    System.out.println("初始化 UserWSImpl");  
    }  
    @Override  
    public UserBean getUserById(int id) {  
    System.out.println("server getUserById:"+id);  
    return new UserBean(1, "张三");  
      
    }  
}

运行输入地址: /ws/自定义的webservice 地址



作者:試毅_思伟


點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優(yōu)質文章

正在加載中
JAVA開發(fā)工程師
手記
粉絲
18
獲贊與收藏
121

關注作者,訂閱最新文章

閱讀免費教程

  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優(yōu)惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號

舉報

0/150
提交
取消