search
HomeDatabaseMysql TutorialProblem with spring+mybatis+axis2 publishing webservice interface on myeclipse
Problem with spring+mybatis+axis2 publishing webservice interface on myeclipseJun 23, 2017 am 11:09 AM
myeclipsewebwebservicereleaseinterface

Premise:

Suddenly one day this month, there was a project docking that required the use of the interface published by axis2. This stumped me. After all, I didn’t even know how to publish the webservice interface before. Later, the first interface - sayHi() was released from HelloWorld; up to this step everything went smoothly. Only when integrating with axis2, a problem occurred. The dao layer of spring was in the interface after axis2 was released. , has always been null, it seems that spring has not been initialized. During this period, I tested to execute a request according to the normal process, and it was correct. However, it did not work after integrating with axis2. During this test, it was very painful. It's very painful. I have tried all imaginable methods one by one, including forced acquisition of dao and singleton mode, but nothing works. So I had to settle for the next best thing, first use spring+mybatis+cxf to publish a usable interface as a proxy, and then use the axis2 box to publish a separate method to call the proxy to achieve project docking. Let's start with the introduction of spring+mybatis+cxf:

1. Create the project directory:

First, we create an entity class Person.java

package com.srit.user.model;public class Person {private String id;  private String name;  private int age;  private String birthday;  private double hight;  public String getId() {  return id;  
    }  public void setId(String id) {  this.id = id;  
    }  public String getName() {  return name;  
    }  public void setName(String name) {  this.name = name;  
    }  public int getAge() {  return age;  
    }  public void setAge(int age) {  this.age = age;  
    }  public String getBirthday() {  return birthday;  
    }  public void setBirthday(String birthday) {  this.birthday = birthday;  
    }  public double getHight() {  return hight;  
    }  public void setHight(double hight) {  this.hight = hight;  
    }  
}

Then let’s first write PersonDao.java in dao. It is an interface. It mainly performs simple addition, deletion, modification and query

package com.srit.user.dao;import java.util.List;import javax.jws.WebMethod;import javax.jws.WebService;import com.srit.user.model.Person;public interface PersonDao {public void insertPerson(Person person);  public void updatePerson(Person person);  public List<person> findPerson(String name);  public void deletePerson(String id);  
}</person>

The following is the implementation class PersonDaoImpl.java

 1 package com.srit.user.dao.impl; 2  3 import java.util.List; 4  5 import javax.annotation.Resource; 6  7 import org.mybatis.spring.SqlSessionTemplate; 8 import org.mybatis.spring.support.SqlSessionDaoSupport; 9 10 import com.srit.user.dao.PersonDao;11 import com.srit.user.model.Person;12 13 public class PersonDaoImpl extends SqlSessionDaoSupport implements PersonDao {14 15     private SqlSessionTemplate sqlSessionTemplate;  
16     17     public SqlSessionTemplate getSqlSessionTemplate() {  
18         return sqlSessionTemplate;  
19     }  
20   21     @Resource(name="sqlSessionTemplate")    
22     public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {  
23         this.sqlSessionTemplate = sqlSessionTemplate;  
24     }  
25   26     public void deletePerson(String id) {  
27         getSqlSession().delete("com.srit.usr.dao.PersonDao.deletePerson", id);  
28     }  
29   30     public List<person> findPerson(String name) {  
31         return getSqlSession().selectList("com.srit.user.dao.PersonDao.findPerson", name);  
32     }  
33   34     public void insertPerson(Person person) {  
35         getSqlSession().insert("com.srit.user.dao.PersonDao.insertPerson", person);  
36     }  
37   38     public void updatePerson(Person person) {  
39         getSqlSession().update("com.srit.user.dao.PersonDao.updatePerson", person);  
40     }  
41   42 43 }</person>

of the dao layer, followed by the service layer PersonService.java

package com.srit.user.service;import java.util.List;import com.srit.user.model.Person;public interface PersonService {public void insertPerson(Person person);  public void updatePerson(Person person);  public List<person> findPerson(String name);  public void deletePerson(String id); 
}</person>

Next is the implementation class of the service layer, PersonServiceImpl.java

package com.srit.user.service.impl;import java.util.List;import javax.annotation.Resource;import org.springframework.stereotype.Service;import org.springframework.transaction.annotation.Transactional;import org.springframework.web.context.ContextLoader;import org.springframework.web.context.WebApplicationContext;import com.srit.user.dao.PersonDao;import com.srit.user.model.Person;import com.srit.user.service.PersonService;

@Service  
@Transactional  
public class PersonServiceImpl implements PersonService {  
      
    @Resource  private PersonDao personDao;  
      public PersonDao getPersonDao() {  return personDao;  
    }  public void setPersonDao(PersonDao personDao) {  this.personDao = personDao;  
//        WebApplicationContext context=ContextLoader.getCurrentWebApplicationContext();//        personDao =(PersonDao)context.getBean("personDao");    }  
  public void deletePerson(String id) {  
        personDao.deletePerson(id);  
    }  
  public List<person> findPerson(String name) {  return personDao.findPerson(name);  
    }  
  public void insertPerson(Person person) {  
        personDao.insertPerson(person);  
    }  
  public void updatePerson(Person person) {  
        personDao.updatePerson(person);  
    }  
  
}</person>

, and then the service interface we want to publish, MyWebservice.java

1 package com.srit.user.webservice;2 3 import com.srit.user.model.Person;4 5 public interface MyWebservice {6     public String czDate(Person person); 
7 }

Of course it must have its implementation class MyWebserviceImpl.java

After get off work. . . Next time I’ll write

The above is the detailed content of Problem with spring+mybatis+axis2 publishing webservice interface on myeclipse. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Web Speech API开发者指南:它是什么以及如何工作Web Speech API开发者指南:它是什么以及如何工作Apr 11, 2023 pm 07:22 PM

​译者 | 李睿审校 | 孙淑娟Web Speech API是一种Web技术,允许用户将语音数据合并到应用程序中。它可以通过浏览器将语音转换为文本,反之亦然。Web Speech API于2012年由W3C社区引入。而在十年之后,这个API仍在开发中,这是因为浏览器兼容性有限。该API既支持短时输入片段,例如一个口头命令,也支持长时连续的输入。广泛的听写能力使它非常适合与Applause应用程序集成,而简短的输入很适合语言翻译。语音识别对可访问性产生了巨大的影响。残疾用户可以使用语音更轻松地浏览

如何使用Docker部署Java Web应用程序如何使用Docker部署Java Web应用程序Apr 25, 2023 pm 08:28 PM

docker部署javaweb系统1.在root目录下创建一个路径test/appmkdirtest&&cdtest&&mkdirapp&&cdapp2.将apache-tomcat-7.0.29.tar.gz及jdk-7u25-linux-x64.tar.gz拷贝到app目录下3.解压两个tar.gz文件tar-zxvfapache-tomcat-7.0.29.tar.gztar-zxvfjdk-7u25-linux-x64.tar.gz4.对解

web端是什么意思web端是什么意思Apr 17, 2019 pm 04:01 PM

web端指的是电脑端的网页版。在网页设计中我们称web为网页,它表现为三种形式,分别是超文本(hypertext)、超媒体(hypermedia)和超文本传输协议(HTTP)。

web前端和后端开发有什么区别web前端和后端开发有什么区别Jan 29, 2023 am 10:27 AM

区别:1、前端指的是用户可见的界面,后端是指用户看不见的东西,考虑的是底层业务逻辑的实现,平台的稳定性与性能等。2、前端开发用到的技术包括html5、css3、js、jquery、Bootstrap、Node.js、Vue等;而后端开发用到的是java、php、Http协议等服务器技术。3、从应用范围来看,前端开发不仅被常人所知,且应用场景也要比后端广泛的太多太多。

web前端打包工具有哪些web前端打包工具有哪些Aug 23, 2022 pm 05:31 PM

web前端打包工具有:1、Webpack,是一个模块化管理工具和打包工具可以将不同模块的文件打包整合在一起,并且保证它们之间的引用正确,执行有序;2、Grunt,一个前端打包构建工具;3、Gulp,用代码方式来写打包脚本;4、Rollup,ES6模块化打包工具;5、Parcel,一款速度极快、零配置的web应用程序打包器;6、equireJS,是一个JS文件和模块加载器。

Python轻量级Web框架:Bottle库!Python轻量级Web框架:Bottle库!Apr 13, 2023 pm 02:10 PM

和它本身的轻便一样,Bottle库的使用也十分简单。相信在看到本文前,读者对python也已经有了简单的了解。那么究竟何种神秘的操作,才能用百行代码完成一个服务器的功能?让我们拭目以待。1. Bottle库安装1)使用pip安装2)下载Bottle文件https://github.com/bottlepy/bottle/blob/master/bottle.py2.“HelloWorld!”所谓万事功成先HelloWorld,从这个简单的示例中,了解Bottle的基本机制。先上代码:首先我们从b

webservice调用webservice调用Jul 05, 2023 pm 03:27 PM

webservice调用步骤:1、需要找到合适的WebService;2、创建WebService客户端并调用相应的方法;3、处理WebService的返回结果和异常;4、通过合理的优化措施,提高WebService调用的效率和性能。

web是前端还是后端web是前端还是后端Aug 24, 2022 pm 04:10 PM

web有前端,也有后端。web前端也被称为“客户端”,是关于用户可以看到和体验的网站的视觉方面,即用户所看到的一切Web浏览器展示的内容,涉及用户可以看到,触摸和体验的一切。web后端也称为“服务器端”,是用户在浏览器中无法查看和交互的所有内容,web后端负责存储和组织数据,并确保web前端的所有内容都能正常工作。web后端与前端通信,发送和接收信息以显示为网页。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools