WebServie

1:Webservice 

@WebService

public interface MessageWebservice {
    public String getName();

}

2:WebserviceImpl

@WebService(endpointInterface = "study.webService.message.messageWS.MessageWebservice")
public class MessageWebserviceImpl implements MessageWebservice {


public String getName(String type,String PageNum,String PageSize) {
// 查询结果
String resultStr = "";
// 数据查询用service(接口 实现类的运用)
MvcService mvcServiceImpl = (MvcService) BeanService.getBean("mvcServiceImpl");
                     

}

3:BeanService

package study.system.service;


import javax.servlet.ServletContext;


import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import org.springframework.web.context.ServletContextAware;


@Component
public class BeanService implements ApplicationContextAware, ServletContextAware
{
/**
* Spring容器上下文
*/
public static ApplicationContext context;


private static ServletContext servletContext;


/**
* 取得Bean对象
* @param beanName bean名
* @return ObjectBean对象 
*/
public static Object getBean(String beanName)
{
if (context != null)
return context.getBean(beanName);

return null;
}


/**
* 判断对象是否存在
* @param beanName
* @return
*/
public static Boolean containsBean(String beanName)
{
if (context != null)
{
return context.containsBean(beanName);
}
return false;
}


/**
* 取得Bean对象
* @param beanName bean名称
* @param clazz bean类型
* @return ObjectBean对象 
*/
public static <T> T getBean(String beanName, Class<T> clazz)
{
if (context != null)
{
return context.getBean(beanName, clazz);
}
return null;
}


/**
* 根据类型取得Bean对象
* @param clazz bean类型
* @return ObjectBean对象 
*/
public static <T> T getBean(Class<T> clazz)
{
if (context != null)
{
return context.getBean(clazz);
}
return null;
}


public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{
context = applicationContext;
}


public static ApplicationContext getContext()
{
return context;
}


public static ServletContext getServletContext()
{
return servletContext;
}


public void setServletContext(ServletContext _servletContext)
{
servletContext = _servletContext;
}
}

4:其中MvcService 就是一般mvc取数据的service

public interface MvcService {

}

5:其中MvcServiceImpl 就是一般mvc取数据的Impl@Service
public class MvcServiceImpl implements MvcService {

}

6:配置文件application-webservice.xml

 <bean id="message" class="study.webService.message.messageWS.impl.MessageWebserviceImpl"/>
 <jaxws:endpoint id="getName" implementor="#message" address="/getName"/>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值