jax-ws spring client 详解

jax-ws spring client 详解
2010-07-06 17:42
1 将 wevservice 客户端 通过<jaxws:client>元素,注入到spring的配置文件中,类似<jaxws:endpoint>元素被用户服务端
2 具体的例子
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jaxws="http://cxf.apache.org/jaxws"
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
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

<jaxws:client id="helloClient"
serviceClass="demo.spring.HelloWorld"
address="http://localhost:9002/HelloWorld" />
</beans>
<jaxws:client>元素说明:
id: String类型,唯一标识,可以被spring的bean进行调用
serviceClass:Class 类型,内容为完整的类名称,SEI 接口名
address:QName 类型,对应wsdl:service@name.
endpointName :QName,对应wsdl:port@name
wsdlLocation:URL类型,A URL to connect to in order to retrieve the WSDL for the service. This is not required
3 更详细的例子
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jaxws="http://cxf.apache.org/jaxws"
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
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

<!-- Interceptors extend e.g. org.apache.cxf.phase.AbstractPhaseInterceptor -->
<bean id="anotherInterceptor" class="..." />

<!-- Handlers implement e.g. javax.xml.ws.handler.soap.SOAPHandler -->
<bean id="jaxwsHandler" class="..." />

<!-- The SOAP client bean -->
<jaxws:client id="helloClient"
serviceClass="demo.spring.HelloWorld"
address="http://localhost:9002/HelloWorld">
<jaxws:inInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
<ref bean="anotherInterceptor"/>
</jaxws:inInterceptor>
<jaxws:handlers>
<ref bean="jaxwsHandler" />
</jaxws:handlers>
<jaxws:properties>
<entry key="mtom-enabled" value="true"/>
</jaxws:properties>
</jaxws:client>
</beans>
<jaxws:client>子元素:
jaxws:inInterceptors:拦截器,必须实现Each should implement org.apache.cxf.interceptor.Interceptor or org.apache.cxf.phase.PhaseInterceptor
jaxws:handlers:处理类,必须实现javax.xml.ws.handler.Handler or javax.xml.ws.handler.soap.SOAPHandler.
jaxws:properties :属性, MAP
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
JAX-WSJava API for XML Web Services)是一种用于构建和部署Web服务的Java API。JAX-WS的jar包是一组提供JAX-WS功能的Java库文件。 JAX-WS的jar包通常包含在Java开发环境(JDK)的库目录中,并可以直接使用。 使用JAX-WS的jar包可以方便地创建和部署Web服务。通过引入JAX-WS的jar包,开发人员可以使用Java语言来开发、发布和消费Web服务。 在使用JAX-WS的jar包之前,我们需要先了解几个重要的概念,例如服务端和客户端的开发、WSDL(Web Services Description Language)描述文件的生成和使用,以及通过SOAP(Simple Object Access Protocol)协议进行通信等。这些概念都是理解和使用JAX-WS的jar包的基础。 当我们在项目中使用JAX-WS的时候,需要将JAX-WS的jar包添加到项目的依赖中。在开发环境中,我们可以直接从Maven等依赖管理工具中获取这些jar包,并将其添加到项目的配置文件中。然后,我们就可以使用JAX-WS提供的类和方法来创建和使用Web服务。 JAX-WS的jar包提供了一系列的API和类,用于处理在开发和部署Web服务时所需要的各种操作,例如创建服务端和客户端的代码、解析和生成WSDL文件、进行SOAP消息的创建和解析等。 总而言之,JAX-WS的jar包为Java开发人员提供了一种简便、高效的方法来创建和使用Web服务。通过使用JAX-WS的jar包,我们可以使用Java语言方便地开发和部署Web服务,并通过SOAP协议进行通信。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值