- 浏览: 1214852 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
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 7070环境 hibernate 4.2.0.Final sp ... -
tomcat 7 应用不能访问 及 配置管理界面
2015-09-16 15:26 2702tomcat 7 应用不能访问 及 配置管理界面 ... -
iteye blog 备份
2015-06-01 11:03 1155以前javaeye有博客导出成pdf的功能, 现在这个功能 ... -
jaxb xml 解析出 list对象
2015-03-26 16:29 10523jaxb想直接解析出list对象, 不用在list对象上再去 ... -
jvm notes
2014-12-16 15:19 1591运行时数据区 program counter re ... -
string split 空字符串问题
2014-09-02 15:02 1883String str="123,123,,1 ... -
IntelliJ IDEA keys
2014-05-29 15:35 1156open type Ctrl+N open ... -
POI excel 触发 公式 计算 删除空白行
2013-04-15 12:44 5040用POI api修改excel 表格数据后, 想触发计算公式 ... -
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated 异常处理
2013-01-05 14:13 3068引用: http://javaskeleton.blogs ... -
MD5 SHA1 Base64 HmacSHA1
2012-10-26 14:23 2139MD5 SHA1 import java.securi ... -
struts2 jsp 禁止 直接 访问
2011-10-13 14:16 3105想要禁止 struts2 应用中 部分jsp 的 直接访问 ... -
jboss-log4j.xml
2011-09-22 17:42 3131使用 jboss_home/server/default/co ... -
jboss 映射 url 虚拟目录 设置system property
2011-08-31 12:56 2159jboss 4.2.3 在[jboss home ... -
jboss 连接池 scheduler
2011-08-04 19:13 1536将oracle-ds.xml 放到 jboss_home\s ... -
jboss Caused by: LifecycleException: Error initializaing : javax.management.R
2011-08-04 14:55 2278Caused by: LifecycleException: ... -
wsdl axis2 spring
2011-04-28 11:12 3273WSDL 文档是利用这些主要的元素来描述某个 web s ... -
apache jboss ssl 配置
2011-03-10 19:37 1564httpd.conf Include "co ... -
cron 表达式
2010-12-13 17:47 1094http://sosuny.iteye.com/blog/46 ... -
资源文件转码
2010-10-27 14:54 1164GBK to utf-8 native2ascii ... -
maven test jar
2010-09-18 11:32 2337多模块的时候 模块之间的test代码也是互相依赖 但默认打包 ...
相关推荐
axis2与spring的集成,在application中配置要发布的Java类,然后配置aar文件,在aar打包文件中的services.xml要嵌入 <parameter name="ServiceObjectSupplier">org.apache.axis2.extensions.spring.receivers....
简单例子:axis2整合spring发布webservice,以及session的管理
axis1.4 spring3.0 集成 实现 web service 服务端, axis1.4 客户端认证,授权,访问日志记录,集成spring 解决 PHP 调用web service 无法认证,和解析soap 模板
WebService从零到项目开发使用2——技术研究 源代码
springboot集成axis2-1.7.9部署和调用实例
NULL 博文链接:https://8324.iteye.com/blog/668274
使用axis2与spring3进行集成,实现的webservice服务。 资料为myeclipse下的web工程,可解压后直接导入。 发布到tomcat6下运行。
Axis2集成Spring发布WebServices服务
Spring集成AXIS2的Web_service配置方法
本示例是在 Axis2 通过 外部 Spring容器 获取指定的实现Bean,以提供服务。全部自己写WSDL和服务实现类,不使用 Axis2提供的 Java2WSDL 和 WSDL2Java 工具
spring集成axis发布webservice源码 spring集成axis发布webservice源码 spring集成axis发布webservice源码 spring集成axis发布webservice源码
axis2 和 spring3.2.0 的包。 这里http://blog.csdn.net/linlinv3/article/details/9017767详细讲解了 axis2 的用法
Spring集成axis2实现webservice所用到的Jar包,将所有的包放到项目的LIB目录下面
axis2-spring-1.5.4.jar是axis2与spring整合时所需要的jar包
NULL 博文链接:https://wujianjun.iteye.com/blog/517152
axis2+spring+ibatis整合的一个项目,含webservice文件传输
axis2+spring2.5整合(webservice)
spring+axis2整合,项目下载之后就能使用,里面简单的编写的发布服务的代码,适合初学者使用
spring+axis集成webservice
axis2_1.5.3.war 解压后的axis2直接放tomcat 下已包含geronimo-stax-api_1.0_spec-1.0.1.jar和backport-util-concurrent-3.1.jar Axis2_Codegen_Wizard_1.3.0.zip和 解压后的文件Axis2_Service_Archiver_1.3.0.zip ...