- 浏览: 1239784 次
- 性别:
- 来自: 上海
-
文章分类
最新评论
-
lankk:
lankk 写道事实上,在运行String s1=new St ...
理解String 及 String.intern() 在实际中的应用 -
lankk:
事实上,在运行String s1=new String(&qu ...
理解String 及 String.intern() 在实际中的应用 -
lankk:
同意1楼的说法http://docs.oracle.com/j ...
理解String 及 String.intern() 在实际中的应用 -
raoyutao:
...
jdk 线程池 ThreadPoolExecutor -
hongdanning:
理解了。之前困惑的一些明白了。谢谢分享。
理解String 及 String.intern() 在实际中的应用
之前写的 http://renxiangzyq.iteye.com/blog/1021112 集成spring axis2 的方法太过复杂,切为了达到需求要对生成的代码做多出修改,极不方便, 网上看了一些文章,发现其实集成axis2 spring很简单
假设你已经有了一个可以用的spring项目
你有一个类要发布成webservice
public class MyService { public Person serviceA(String name, Integer age) { Person person = new Person(); person.setAge(age); person.setName(name); City city = new City(); city.setName("shanghai"); city.setZone("east"); person.setCity(city); return person; } }
1. 下载axsi2.war 这个在 axis2官网有下,把他WEB-INF目录下的conf, lib, modules, services目录都copy到你的WEB-INF下, 其实lib里面的jar应该不用全copy的,有时间可以去筛选
2. 在你的web.xml加入以下
<servlet> <servlet-name>AxisServlet</servlet-name> <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>AxisServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping>
3. 在你的application-context.xml里加入
<bean id="applicationContext" class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" /> <bean id="springAwareService" class="com.axisspring.service.MyService"> </bean>
4. 在你的WEB-INF/services下, 建立 ./test/META-INF/services.xml, 里面的内容为
<?xml version="1.0" encoding="UTF-8"?> <service name="testService"> <description>simple spring example</description> <parameter name="ServiceObjectSupplier"> org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier </parameter> <parameter name="SpringBeanName">springAwareService </parameter> <messageReceivers> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" /> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> </messageReceivers> </service>
然后就是部署了, 因为我在web.xml里面拦截的是/services/*, 在services.xml里面配的是testService,所以我的webservice地址是
http://localhost:8080/axisspring/services/testService?wsdl,
生成的wsdl如下
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://service.axisspring.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax21="http://service.axisspring.com/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://service.axisspring.com"> <wsdl:documentation>testService</wsdl:documentation> <wsdl:types> <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.axisspring.com/xsd"> <xs:complexType name="Person"> <xs:sequence> <xs:element minOccurs="0" name="age" type="xs:int"/> <xs:element minOccurs="0" name="city" nillable="true" type="ax21:City"/> <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:complexType name="City"> <xs:sequence> <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/> <xs:element minOccurs="0" name="zone" nillable="true" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:schema> <xs:schema xmlns:ax22="http://service.axisspring.com/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.axisspring.com"> <xs:import namespace="http://service.axisspring.com/xsd"/> <xs:element name="serviceA"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/> <xs:element minOccurs="0" name="age" type="xs:int"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="serviceAResponse"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="return" nillable="true" type="ax22:Person"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </wsdl:types> <wsdl:message name="serviceARequest"> <wsdl:part name="parameters" element="ns:serviceA"/> </wsdl:message> <wsdl:message name="serviceAResponse"> <wsdl:part name="parameters" element="ns:serviceAResponse"/> </wsdl:message> <wsdl:portType name="testServicePortType"> <wsdl:operation name="serviceA"> <wsdl:input message="ns:serviceARequest" wsaw:Action="urn:serviceA"/> <wsdl:output message="ns:serviceAResponse" wsaw:Action="urn:serviceAResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="testServiceSoap11Binding" type="ns:testServicePortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <wsdl:operation name="serviceA"> <soap:operation soapAction="urn:serviceA" style="document"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:binding name="testServiceSoap12Binding" type="ns:testServicePortType"> <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <wsdl:operation name="serviceA"> <soap12:operation soapAction="urn:serviceA" style="document"/> <wsdl:input> <soap12:body use="literal"/> </wsdl:input> <wsdl:output> <soap12:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:binding name="testServiceHttpBinding" type="ns:testServicePortType"> <http:binding verb="POST"/> <wsdl:operation name="serviceA"> <http:operation location="testService/serviceA"/> <wsdl:input> <mime:content type="text/xml" part="serviceA"/> </wsdl:input> <wsdl:output> <mime:content type="text/xml" part="serviceA"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="testService"> <wsdl:port name="testServiceHttpSoap11Endpoint" binding="ns:testServiceSoap11Binding"> <soap:address location="http://localhost:8080/axisspring/services/testService.testServiceHttpSoap11Endpoint/"/> </wsdl:port> <wsdl:port name="testServiceHttpSoap12Endpoint" binding="ns:testServiceSoap12Binding"> <soap12:address location="http://localhost:8080/axisspring/services/testService.testServiceHttpSoap12Endpoint/"/> </wsdl:port> <wsdl:port name="testServiceHttpEndpoint" binding="ns:testServiceHttpBinding"> <http:address location="http://localhost:8080/axisspring/services/testService.testServiceHttpEndpoint/"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
把这个wsdl保存成文件, 用soapui测试, 可以正常使用
有些要提的地方,
所有public方法自动发布成webservice
函数的输入自动匹配成webservice的输入, 返回成输出,
如果我的返回数据不止一个, 比如上面我就包装了一个person, 所以返回的数据的顶层节点就是一个person, person里面可以有很多节点,很多层,
但假如我想要返回的是2个顶层的节点,就不知道怎么弄了, 我试过返回一个map里面放2个数据, 但不行,之前的那篇文章的集成方法就可以返回2个顶层的节点
还有假如要返回数组, 返回文件流 等 也还没有去研究
发表评论
-
连接池exception GetConnectionTimeoutException get/close not same thread
2015-09-24 14:44 7141环境 hibernate 4.2.0.Final sp ... -
tomcat 7 应用不能访问 及 配置管理界面
2015-09-16 15:26 2763tomcat 7 应用不能访问 及 配置管理界面 ... -
iteye blog 备份
2015-06-01 11:03 1212以前javaeye有博客导出成pdf的功能, 现在这个功能 ... -
jaxb xml 解析出 list对象
2015-03-26 16:29 10661jaxb想直接解析出list对象, 不用在list对象上再去 ... -
jvm notes
2014-12-16 15:19 1759运行时数据区 program counter re ... -
string split 空字符串问题
2014-09-02 15:02 1961String str="123,123,,1 ... -
IntelliJ IDEA keys
2014-05-29 15:35 1211open type Ctrl+N open ... -
POI excel 触发 公式 计算 删除空白行
2013-04-15 12:44 5113用POI api修改excel 表格数据后, 想触发计算公式 ... -
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated 异常处理
2013-01-05 14:13 3247引用: http://javaskeleton.blogs ... -
MD5 SHA1 Base64 HmacSHA1
2012-10-26 14:23 2202MD5 SHA1 import java.securi ... -
struts2 jsp 禁止 直接 访问
2011-10-13 14:16 3170想要禁止 struts2 应用中 部分jsp 的 直接访问 ... -
jboss-log4j.xml
2011-09-22 17:42 3188使用 jboss_home/server/default/co ... -
jboss 映射 url 虚拟目录 设置system property
2011-08-31 12:56 2249jboss 4.2.3 在[jboss home ... -
jboss 连接池 scheduler
2011-08-04 19:13 1586将oracle-ds.xml 放到 jboss_home\s ... -
jboss Caused by: LifecycleException: Error initializaing : javax.management.R
2011-08-04 14:55 2335Caused by: LifecycleException: ... -
wsdl axis2 spring
2011-04-28 11:12 3336WSDL 文档是利用这些主要的元素来描述某个 web s ... -
apache jboss ssl 配置
2011-03-10 19:37 1616httpd.conf Include "co ... -
cron 表达式
2010-12-13 17:47 1144http://sosuny.iteye.com/blog/46 ... -
资源文件转码
2010-10-27 14:54 1211GBK to utf-8 native2ascii ... -
maven test jar
2010-09-18 11:32 2402多模块的时候 模块之间的test代码也是互相依赖 但默认打包 ...
相关推荐
当我们谈论"Axis2 Spring整合POJO开发Web服务"时,这意味着我们将使用Axis2来创建Web服务,并通过Spring框架来管理和控制这些服务,同时利用POJO(Plain Old Java Object)作为业务逻辑的核心。 首先,让我们深入...
### Axis2集成Spring知识点 #### 一、概览 本文档旨在介绍如何将Apache Axis2与Spring框架进行集成,以实现灵活的服务部署和管理。在实际应用中,开发者可能需要利用Spring来管理业务对象(例如POJOs),并希望...
- Axis2还集成了Spring框架,允许更灵活的业务逻辑集成,以及对JSON的支持,扩展了其在不同技术栈中的应用。 2. **Axis2的安装与配置**: - 用户可以从Apache官方网站下载Axis2的最新版本,例如1.4.1。 - 安装...
Axis2与Spring的结合使得开发者能够在构建WebService的同时利用Spring的强大功能。 - **JSON支持**:JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,易于人阅读和编写,同时也易于机器解析和生成...
此外,Axis2不仅支持SOAP 1.1和1.2,还集成了RESTful Web服务和Spring、JSON等流行技术,使得开发更加多样和便捷。 在开始学习之前,学员需要下载并安装Axis2。从Apache官方网站http://ws.apache.org/axis2/获取...
3. **集成Spring框架**:AXIS2与Spring框架紧密集成,使得服务的部署和管理更加便捷。 4. **JSON支持**:AXIS2支持JSON(JavaScript Object Notation)数据格式,方便与AJAX和其他轻量级客户端进行交互。 5. **模块...
Axis2不仅支持传统的SOAP1.1和SOAP1.2标准,还与时俱进地兼容了RESTful WebService、Spring框架、JSON等现代技术栈。这使得Axis2成为了一个既能满足传统企业级应用需求,又能灵活应对现代轻量级Web服务开发的全能型...
- **应用场景**:Axis2广泛应用于各种集成场景中,例如: - 发布服务端Java类的方法,以便于跨平台、跨语言的客户端访问。 - 在面向服务的架构(SOA)中作为服务间通信的基础组件。 - 作为企业级应用的集成方案之一...
Axis2 提供了更高效、更灵活的架构,支持 SOAP 1.1 和 SOAP 1.2 协议,并且集成了 RESTful Web Services。除此之外,它还兼容 Spring 框架以及 JSON 数据格式,极大地扩展了其功能范围。在后续的教程中,将会详细...
将编译后的`HelloWorldService.class`文件放置于Tomcat的`webapps/axis2/WEB-INF/pojo`目录下,通过浏览器访问`http://localhost:8080/axis2/HelloWorldService?wsdl`获取WSDL文件,或直接调用服务。 #### 四、进阶...
- **支持标准全面**:Axis2不仅支持SOAP 1.1和SOAP 1.2标准,还集成了流行的RESTful Web Service,并且兼容Spring框架和JSON技术,极大地拓宽了其应用场景。 - **灵活的应用模式**:可以作为独立的服务引擎运行,也...
由于 Axis2 集成了 Spring,因此可以直接将由 Spring 管理的 Bean 发布为 WebService,方便依赖注入和事务管理。 **8、异步调用 WebService** Axis2 支持异步调用模式,客户端可以非阻塞地发起请求,提高系统性能。...
Axis2可以与Spring框架集成,直接将Spring管理的JavaBean发布为Web服务,这样可以利用Spring的依赖注入和管理特性,提升服务的可维护性和灵活性。 8. **异步调用WebService**: 支持异步调用模式,使得客户端可以...
6. **集成Spring框架**:Axis2可以与Spring框架无缝集成,使得服务的依赖注入和管理更加简便,同时也方便了服务的部署和测试。 7. **JSON支持**:除了XML(通过SOAP)之外,Axis2还支持JSON数据格式,JSON通常用于...
在【描述】中,我们了解到Axis2广泛应用于发布服务端的Java类方法,使得不同客户端能够调用,从而促进不同技术的集成。它在SOA(面向服务架构)中也扮演着重要角色,用于不同组件间的数据交换。课程内容涵盖Axis2的...
- Axis2的一大优势在于其对POJO(Plain Old Java Object)的支持,可以实现零配置发布Web服务。只需将具有公共方法的POJO类放在指定位置,Axis2会自动将其转换为Web服务。 - 例如,我们创建一个名为`SimpleService...
Axis2作为WebService引擎,能够帮助开发者发布Java类的方法为Web服务,允许不同客户端进行调用,从而实现技术的集成。 课程内容包括了Axis2的基础知识讲解,如以多种方式编写和发布WebService、JAX-RPC、JAX-WS的...
Axis2不仅支持SOAP 1.1和SOAP 1.2协议,而且还引入了对RESTful Web服务的支持,同时集成了Spring框架和JSON等流行技术。本教程将详细介绍如何使用Axis2创建无需配置文件的Web服务,并演示如何使用Java和C#进行客户端...
Axis2是Apache软件基金会提供的一款高性能、轻量级的WebService引擎,它是在Axis1.x的基础上重新设计的产物,不仅支持SOAP1.1和SOAP1.2协议,还扩展了对RESTful WebService的支持,以及Spring框架和JSON技术的集成。...