- 浏览: 2542151 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Spring3 and Axis2 Integration(I)
I use spring3 and axis2.
1. we will have our spring configuration file and our spring bean configuration
main-context.xml:
<context:annotation-config />
<context:component-scan base-package="com.sillycat">
</context:component-scan>
<import resource="classpath:resource-context.xml" />
<import resource="classpath:core-context.xml" />
<import resource="classpath:dao-context.xml" />
<import resource="classpath:manager-context.xml" />
<import resource="classpath:service-easyaxis2proxy-context.xml" />
our webservice bean configuration file service-easyaxis2proxy-context.xml:
<bean id="personService" class="com.sillycat.easyaxis2proxy.service.PersonServiceImpl" >
<property name="personManager" ref="personManager"/>
</bean>
2. axis2 configuration is as the same as we did in easyaxis project
3. spring3 axis2 intergration
We will not have aar file, we will put the configuration file WEB-INF/services/PersonService/META-INF/services.xml
<?xml version="1.0" encoding="UTF-8"?>
<service name="PersonService">
<description>
Person Demo Service
</description>
<parameter name="ServiceObjectSupplier">
org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
</parameter>
<parameter name="SpringBeanName">
personService
</parameter>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
</messageReceivers>
</service>
We can call spring bean named personService in our axis2 services.xml file directly.
Our web.xml will as follow:
<display-name>easyaxis2proxy</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:main-context.xml</param-value>
</context-param>
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
<!-- axis2 start -->
<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>
<servlet-name>SOAPMonitorService</servlet-name>
<servlet-class>
org.apache.axis2.soapmonitor.servlet.SOAPMonitorService
</servlet-class>
<init-param>
<param-name>SOAPMonitorPort</param-name>
<param-value>5001</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>*.jws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SOAPMonitorService</servlet-name>
<url-pattern>/SOAPMonitor</url-pattern>
</servlet-mapping>
4. Everything is ok, we can visit the listservice page
http://localhost:8080/easyaxis2proxy/services/listServices
we can get the WSDL file from here:
http://localhost:8080/easyaxis2proxy/services/PersonService?wsdl
5. Run my junit test, PersonServiceRemoteTest:
package com.sillycat.easyaxis2proxy.remote;
import javax.xml.namespace.QName;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
import org.apache.axis2.transport.http.HTTPConstants;
import com.sillycat.core.BaseTestCase;
import com.sillycat.easyjpa.model.Person;
public class PersonServiceRemoteTest extends BaseTestCase
{
public void setUp() throws Exception
{
super.setUp();
}
public void tearDown() throws Exception
{
super.tearDown();
}
@SuppressWarnings("unchecked")
public void testGet()
{
RPCServiceClient serviceClient = null;
try
{
serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
EndpointReference targetEPR = new EndpointReference("http://localhost:8080/easyaxis2proxy/services/PersonService");
options.setTimeOutInMilliSeconds(1800000); // 10000 seconds
options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
options.setProperty(HTTPConstants.SO_TIMEOUT, 1800000);
options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, 1800000);
options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
options.setExceptionToBeThrownOnSOAPFault(true);
options.setTo(targetEPR);
// Getting the person
QName opGet = new QName("http://service.easyaxis2proxy.sillycat.com", "get");
Object[] opGetArgs = new Object[] { 2 };
Class[] returnTypes = new Class[] { Person.class };
Object[] response = serviceClient.invokeBlocking(opGet, opGetArgs, returnTypes);
Person result = (Person) response[0];
if (result == null)
{
System.out.println("Person didn't initialize!");
return;
}
// Displaying the result
System.out.println("Name : " + result.getName());
System.out.println("Age : " + result.getAge());
System.out.println("Birthday : " + result.getBirthday());
System.out.println("Sex : " + result.getSex());
System.out.println("Id : " + result.getId());
}
catch (Exception e)
{
System.out.println("error:" + e);
}
finally
{
try
{
// clear up
serviceClient.cleanupTransport();
}
catch (Exception e)
{
System.out.println("error:" + e);
}
}
}
}
I got this error message when I run my junit test:
date string can not be less than 19 charactors
It seems that the axis2 can not deal with Date type well. So I think the easiest way to do this is to trans Date to String in WebService level.
ok, everything is running well, the sample project is easyaxis2proxy.
references:
http://wujianjun.iteye.com/blog/517150
http://wujianjun.iteye.com/blog/517152
http://axis.apache.org/axis2/java/core/docs/spring.html
http://cheney-mydream.iteye.com/blog/390232
I use spring3 and axis2.
1. we will have our spring configuration file and our spring bean configuration
main-context.xml:
<context:annotation-config />
<context:component-scan base-package="com.sillycat">
</context:component-scan>
<import resource="classpath:resource-context.xml" />
<import resource="classpath:core-context.xml" />
<import resource="classpath:dao-context.xml" />
<import resource="classpath:manager-context.xml" />
<import resource="classpath:service-easyaxis2proxy-context.xml" />
our webservice bean configuration file service-easyaxis2proxy-context.xml:
<bean id="personService" class="com.sillycat.easyaxis2proxy.service.PersonServiceImpl" >
<property name="personManager" ref="personManager"/>
</bean>
2. axis2 configuration is as the same as we did in easyaxis project
3. spring3 axis2 intergration
We will not have aar file, we will put the configuration file WEB-INF/services/PersonService/META-INF/services.xml
<?xml version="1.0" encoding="UTF-8"?>
<service name="PersonService">
<description>
Person Demo Service
</description>
<parameter name="ServiceObjectSupplier">
org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
</parameter>
<parameter name="SpringBeanName">
personService
</parameter>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
</messageReceivers>
</service>
We can call spring bean named personService in our axis2 services.xml file directly.
Our web.xml will as follow:
<display-name>easyaxis2proxy</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:main-context.xml</param-value>
</context-param>
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
<!-- axis2 start -->
<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>
<servlet-name>SOAPMonitorService</servlet-name>
<servlet-class>
org.apache.axis2.soapmonitor.servlet.SOAPMonitorService
</servlet-class>
<init-param>
<param-name>SOAPMonitorPort</param-name>
<param-value>5001</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>*.jws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SOAPMonitorService</servlet-name>
<url-pattern>/SOAPMonitor</url-pattern>
</servlet-mapping>
4. Everything is ok, we can visit the listservice page
http://localhost:8080/easyaxis2proxy/services/listServices
we can get the WSDL file from here:
http://localhost:8080/easyaxis2proxy/services/PersonService?wsdl
5. Run my junit test, PersonServiceRemoteTest:
package com.sillycat.easyaxis2proxy.remote;
import javax.xml.namespace.QName;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
import org.apache.axis2.transport.http.HTTPConstants;
import com.sillycat.core.BaseTestCase;
import com.sillycat.easyjpa.model.Person;
public class PersonServiceRemoteTest extends BaseTestCase
{
public void setUp() throws Exception
{
super.setUp();
}
public void tearDown() throws Exception
{
super.tearDown();
}
@SuppressWarnings("unchecked")
public void testGet()
{
RPCServiceClient serviceClient = null;
try
{
serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
EndpointReference targetEPR = new EndpointReference("http://localhost:8080/easyaxis2proxy/services/PersonService");
options.setTimeOutInMilliSeconds(1800000); // 10000 seconds
options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
options.setProperty(HTTPConstants.SO_TIMEOUT, 1800000);
options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, 1800000);
options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
options.setExceptionToBeThrownOnSOAPFault(true);
options.setTo(targetEPR);
// Getting the person
QName opGet = new QName("http://service.easyaxis2proxy.sillycat.com", "get");
Object[] opGetArgs = new Object[] { 2 };
Class[] returnTypes = new Class[] { Person.class };
Object[] response = serviceClient.invokeBlocking(opGet, opGetArgs, returnTypes);
Person result = (Person) response[0];
if (result == null)
{
System.out.println("Person didn't initialize!");
return;
}
// Displaying the result
System.out.println("Name : " + result.getName());
System.out.println("Age : " + result.getAge());
System.out.println("Birthday : " + result.getBirthday());
System.out.println("Sex : " + result.getSex());
System.out.println("Id : " + result.getId());
}
catch (Exception e)
{
System.out.println("error:" + e);
}
finally
{
try
{
// clear up
serviceClient.cleanupTransport();
}
catch (Exception e)
{
System.out.println("error:" + e);
}
}
}
}
I got this error message when I run my junit test:
date string can not be less than 19 charactors
It seems that the axis2 can not deal with Date type well. So I think the easiest way to do this is to trans Date to String in WebService level.
ok, everything is running well, the sample project is easyaxis2proxy.
references:
http://wujianjun.iteye.com/blog/517150
http://wujianjun.iteye.com/blog/517152
http://axis.apache.org/axis2/java/core/docs/spring.html
http://cheney-mydream.iteye.com/blog/390232
发表评论
-
Stop Update Here
2020-04-28 09:00 310I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 468NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 361Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 364Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 328Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 422Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 428Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 364Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 444VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 376Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 466NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 413Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 330Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 242GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 443GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 320GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 306Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 310Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 285Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 302Serverless with NodeJS and Tenc ...
相关推荐
3. **Spring整合Axis2** 整合Spring和Axis2,主要是为了利用Spring的依赖注入和管理能力,以及Axis2的Web服务处理能力。整合过程主要包括以下步骤: - 配置Spring容器:首先在Spring配置文件中定义Web服务的bean,...
Spring框架提供了两种主要的方式来实现Web服务:Spring-WS和Spring-Integration的Web服务支持。在这个场景中,描述中提到的是基于Apache Axis的实现,这可能涉及到Spring与Apache Axis的集成,Axis是一个流行的SOAP...
3. 使用Axis插件生成客户端:在命令行中,你可以使用Axis的wsdl2java工具,输入Web服务的WSDL URL或本地WSDL文件路径,该工具会自动生成对应的客户端Java stubs(存根类)。这些存根类包含了调用Web服务所需的所有...
2. **UDDI(Universal Description, Discovery, and Integration)**:一种用于发现Web服务的目录服务标准。 3. **SOAP**:基于XML的协议,用于交换结构化信息。SOAP消息包含一个或多个操作调用。 4. **WS-I(Web ...
WebService的核心技术包括SOAP(Simple Object Access Protocol)、WSDL(Web Services Description Language)和UDDI(Universal Description, Discovery, and Integration)。 【axis篇】 AXIS是Apache软件基金会...
4. UDDI(Universal Description, Discovery, and Integration)是一个目录服务,用于发布和查找Web服务。 二、Apache Axis1简介 Apache Axis是Apache软件基金会开发的一个开源项目,用于构建和部署Web服务。Axis1...
这种技术的核心在于利用SOAP(Simple Object Access Protocol)作为消息传输机制,WSDL(Web Services Description Language)用于描述服务,以及UDDI(Universal Description, Discovery, and Integration)作为...
SOAP(Simple Object Access Protocol)作为消息传输协议,WSDL(Web Services Description Language)来定义服务接口,以及UDDI(Universal Description, Discovery, and Integration)用于服务注册和发现。...
Spring框架提供了对WebService的全面支持,可以通过Spring-WS或Spring-Integration模块方便地集成各种Web服务框架,如Axis2。Spring的依赖注入和AOP特性使得Web服务的开发更加灵活和易于测试。 7. 安全性考虑: ...
WebService规范包括描述服务的WSDL(Web Service Description Language)、定位服务的UDDI(Universal Description, Discovery and Integration)以及通信协议SOAP(Simple Object Access Protocol)。 #### ...
2. **Spring框架**: Spring以其依赖注入(DI)和面向切面编程(AOP)闻名,是Java开发中的基石。它简化了企业级应用的复杂性,通过提供事务管理、数据访问、安全管理等服务,使开发者能够专注于业务逻辑。 3. **...
- **UDDI**(Universal Description, Discovery and Integration):是服务发布和发现的标准,使得服务提供者能够登记服务,服务请求者能够搜索服务。 3. **XFire简介**: - XFire是一个快速发展的Web Service...
通过深入学习这些文档,开发者可以掌握Web服务的核心概念,以及如何使用Apache Axis2和Spring框架来有效地开发和集成Web服务。这将有助于提高Java开发者在分布式系统和企业级应用开发中的技能。
3. **Axis与Spring集成** - Spring框架是一个强大的企业级应用开发框架,它可以与Axis集成以管理Web服务的生命周期,实现依赖注入,并提供事务管理和安全控制等高级功能。 4. **开发流程与工具** - 使用Axis进行...
5.4.2 Culling with Axis-Aligned Bounding Boxes 354 5.5 Variations 361 Chapter Physics and Shader Programs 6.1 Introduction 6.2 vertex and pixel shaders 6.3 Deformation by vertex Displacement ...
它们通常基于SOAP(Simple Object Access Protocol)协议,使用WSDL(Web Services Description Language)进行描述,并通过UDDI(Universal Description, Discovery, and Integration)服务进行发布和查找。...
3. "使用services.xml文件发布WebService":这集内容深入解析了如何使用services.xml文件来定义和部署Web服务,这是Axis2中一个关键的配置文件。 4. "二进制文件传输":针对Web服务中可能涉及的非文本数据,如图片...
WSDL(Web Services Description Language)用于定义服务接口,UDDI(Universal Description, Discovery, and Integration)则提供服务注册和查找功能。这些技术共同构建了Web服务的基础架构。 二、XFire框架 XFire...
1. **Web服务基础**:介绍Web服务的基本概念,包括SOAP、WSDL、UDDI(Universal Description, Discovery, and Integration)等标准。 2. **Axis框架详解**:深入解析Axis的工作原理,如何创建、部署和调用Web服务,...