实体类:
package com.mport.entity; import javax.persistence.Entity; import javax.persistence.Table; @Entity @Table(name = "comic_classify") public class ComicClassify extends ClassifyBase { private static final long serialVersionUID = -6295918636095140391L; }
package abeop.service.bean; public class SubInfo implements java.io.Serializable { private static final long serialVersionUID = -8961532006519378167L; private java.lang.String accessCode; private java.lang.String command; private NamedParameter[] extensionInfo; private java.lang.Integer isAutoExtend; private java.lang.String operCode; private int payType; private java.lang.String productID; private int subType; public java.lang.String getAccessCode() { return accessCode; } public void setAccessCode(java.lang.String accessCode) { this.accessCode = accessCode; } public java.lang.String getCommand() { return command; } public void setCommand(java.lang.String command) { this.command = command; } public NamedParameter[] getExtensionInfo() { return extensionInfo; } public void setExtensionInfo(NamedParameter[] extensionInfo) { this.extensionInfo = extensionInfo; } public java.lang.Integer getIsAutoExtend() { return isAutoExtend; } public void setIsAutoExtend(java.lang.Integer isAutoExtend) { this.isAutoExtend = isAutoExtend; } public java.lang.String getOperCode() { return operCode; } public void setOperCode(java.lang.String operCode) { this.operCode = operCode; } public int getPayType() { return payType; } public void setPayType(int payType) { this.payType = payType; } public java.lang.String getProductID() { return productID; } public void setProductID(java.lang.String productID) { this.productID = productID; } public int getSubType() { return subType; } public void setSubType(int subType) { this.subType = subType; } }
package abeop.service.bean; public class NamedParameter implements java.io.Serializable { private static final long serialVersionUID = -9076491524279015792L; private java.lang.String key; private java.lang.String value; public java.lang.String getKey() { return key; } public void setKey(java.lang.String key) { this.key = key; } public java.lang.String getValue() { return value; } public void setValue(java.lang.String value) { this.value = value; } }
获取spring bean 的工具类:
package com.mport.common; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; public class ApplicationContextUtils implements ApplicationContextAware { private static ApplicationContext context = null; public void setApplicationContext(ApplicationContext context) throws BeansException { this.context = context; } public static ApplicationContext getContext() { return context; } }
配置到spring.xml中:
<bean class="com.mport.common.ApplicationContextUtils"/>
WEB SERVICE接口代码:
package abeop.service; import java.util.HashMap; import java.util.Map; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebParam.Mode; import javax.jws.WebResult; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import javax.xml.bind.annotation.XmlSeeAlso; import net.sf.json.JSONSerializer; import org.apache.commons.lang.StringUtils; import abeop.service.bean.NamedParameter; import abeop.service.bean.SeriesType; import abeop.service.bean.SubInfo; import abeop.service.req.AbstractRequest; import abeop.service.req.GenerateUrlListRequest; import abeop.service.req.GetClassifyListRequest; import abeop.service.req.GetOpusListRequest; import abeop.service.req.SubscribeHistoryRequest; import abeop.service.req.SubscribeProductRequest; import abeop.service.req.UnsubscribeProductRequest; import abeop.service.req.ViewChapterDetailRequest; import abeop.service.req.ViewOpusDetailRequest; import abeop.service.rsp.GenerateUrlListResponse; import abeop.service.rsp.GetClassifyListResponse; import abeop.service.rsp.GetOpusListResponse; import abeop.service.rsp.SubscribeHistoryResponse; import abeop.service.rsp.SubscribeProductResponse; import abeop.service.rsp.UnsubscribeProductResponse; import abeop.service.rsp.ViewChapterDetailResponse; import abeop.service.rsp.ViewOpusDetailResponse; import com.huawei.portalone.storefront.service.bean.UserID; import com.huawei.portalone.storefront.service.response.AuthSubscriptionRsp; import com.mport.common.ApplicationContextUtils; import com.mport.common.ServiceInterfaceUtils; import com.mport.entity.ComicClassify; import com.mport.service.ComicClassifyService; import com.mport.service.LoggerService; /** * 接口入口 * * @author lzq * */ @WebService(name = "portalService", serviceName = "PortalService", targetNamespace = "http://abeop/service") @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.BARE) @XmlSeeAlso({ ComicClassify.class, SubInfo.class, NamedParameter.class }) public class PortalService { private ComicClassifyService comicClassifyService; private LoggerService loggerService; private boolean toLog = false; public PortalService() { init(); } private synchronized void init() { if (comicClassifyService == null) { comicClassifyService = (com.mport.service.ComicClassifyService) ApplicationContextUtils.getContext().getBean("comicClassifyService"); } if (loggerService == null) { loggerService = (com.mport.service.LoggerService) ApplicationContextUtils.getContext().getBean("loggerService"); } } /** * 取得分类列表 * * @param req * @return */ @WebMethod(operationName = "getClassifyList", action = "urn:getClassifyList") @WebResult(name = "GetClassifyListResponse", targetNamespace = "http://abeop/service/rsp") public GetClassifyListResponse getClassifyList(@WebParam(mode = Mode.IN, targetNamespace = "http://abeop/service/req") GetClassifyListRequest req) { GetClassifyListResponse rsp = new GetClassifyListResponse(); if (CheckParams.checkSeriesTypeParam(req, rsp) & CheckParams.checkPageParam(req, rsp)) { SeriesType seriesType = SeriesType.valueOf(req.getSeriesType().toUpperCase()); switch (seriesType) { case COMIC: rsp.setClassifyList(comicClassifyService.getComicClassifyList((req.getPageNum() - 1) * req.getPageSize(), req.getPageSize())); break; default: break; } } return rsp; } /** * 取得作品列表 * * @param req * @return */ public GetOpusListResponse getOpusList(GetOpusListRequest req) { return null; } /** * 取得作品详情 * * @param req * @return */ public ViewOpusDetailResponse viewOpusDetail(ViewOpusDetailRequest req) { return null; } /** * 查看章节详情 * * @param req * @return */ public ViewChapterDetailResponse viewChapterDetail(ViewChapterDetailRequest req) { return null; } /** * 订购产品 * * @param req * @return */ @WebMethod(operationName = "subscribeProduct", action = "urn:subscribeProduct") @WebResult(name = "SubscribeProductResponse", targetNamespace = "http://abeop/service/rsp") public SubscribeProductResponse subscribeProduct(@WebParam(mode = Mode.IN, targetNamespace = "http://abeop/service/req") SubscribeProductRequest req) { UserID userID = new UserID(); userID.setID(req.getPhoneNum()); userID.setType(req.getUserType()); try { AuthSubscriptionRsp rsp = ServiceInterfaceUtils.authSubscription(loggerService, toLog, recLog(req), req.getContentCode(), req.getObjectType(), userID, req.getLang(), 1); System.out.println(JSONSerializer.toJSON(rsp).toString(2)); } catch (Exception e) { e.printStackTrace(); } // SubscribeProductRsp rsp = ServiceInterfaceUtils.subscribeProduct(loggerService, toLog, columnAndValuesPart, userID, subInfoArray, 1); return null; } /** * 退购产品 * * @param req * @return */ public UnsubscribeProductResponse unsubscribeProduct(UnsubscribeProductRequest req) { return null; } /** * 订购历史 * * @param req * @return */ public SubscribeHistoryResponse subscribeHistory(SubscribeHistoryRequest req) { return null; } /** * 生成地址 * * @param req * @return */ public GenerateUrlListResponse generateUrlList(GenerateUrlListRequest req) { return null; } @WebMethod(exclude = true) public Map<String, Object> recLog(AbstractRequest req) throws Exception { Map<String, Object> columnAndValuesPart = new HashMap<String, Object>(); columnAndValuesPart.put("channel_id", StringUtils.isNotBlank(req.getChid()) ? req.getChid() : null); columnAndValuesPart.put("ua", StringUtils.isNotBlank(req.getUa()) ? req.getUa() : null); columnAndValuesPart.put("plantform", StringUtils.isNotBlank(req.getP()) ? req.getP() : null); columnAndValuesPart.put("plantform_version", StringUtils.isNotBlank(req.getPv()) ? req.getPv() : null); columnAndValuesPart.put("client_version", StringUtils.isNotBlank(req.getCv()) ? req.getCv() : null); return columnAndValuesPart; } public static void main(String[] args) { PortalService p = new PortalService(); GetClassifyListRequest req = new GetClassifyListRequest(); req.setSeriesType("comic"); req.setPageNum(1); req.setPageSize(1); GetClassifyListResponse rsp = p.getClassifyList(req); System.out.println(JSONSerializer.toJSON(rsp).toString(2)); } }
package abeop.service; import java.util.ResourceBundle; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.NumberUtils; import abeop.service.bean.SubInfo; import abeop.service.req.ContentRequest; import abeop.service.req.PageRequest; import abeop.service.req.ProductRequest; import abeop.service.req.SeriesTypeRequest; import abeop.service.req.UserRequest; import abeop.service.rsp.AbstractResponse; public class CheckParams { private static ResourceBundle bundle; static { if (bundle == null) { bundle = ResourceBundle.getBundle("abeop_code"); } } public static boolean checkPageParam(PageRequest req, AbstractResponse rsp) { boolean bool = false; if (req.getPageNum() == null || req.getPageNum() <= 0) { rsp.setResultCode(NumberUtils.toInt(bundle.getString("code_page_num"))); rsp.setResultMsg(bundle.getString("msg_page_num")); } else if (req.getPageSize() == null || req.getPageSize() <= 0) { rsp.setResultCode(NumberUtils.toInt(bundle.getString("code_page_size"))); rsp.setResultMsg(bundle.getString("msg_page_size")); } else { bool = true; } return bool; } /** * 检查动漫画分类 * * @param req * @param rsp * @return */ public static boolean checkSeriesTypeParam(SeriesTypeRequest req, AbstractResponse rsp) { boolean bool = false; if (StringUtils.isBlank(req.getSeriesType())) { rsp.setResultCode(NumberUtils.toInt(bundle.getString("code_series_type"))); rsp.setResultMsg(bundle.getString("msg_series_type")); } else { bool = true; } return bool; } /** * 检查手机号码 * * @param req * @param rsp * @return */ public static boolean checkPhoneNumParam(UserRequest req, AbstractResponse rsp) { boolean bool = false; if (StringUtils.isBlank(req.getPhoneNum())) { rsp.setResultCode(NumberUtils.toInt(bundle.getString("code_phone_num"))); rsp.setResultMsg(bundle.getString("msg_phone_num")); } else { bool = true; } return bool; } /** * 检查用户类型 * * @param req * @param rsp * @return */ public static boolean checkUserTypeParam(UserRequest req, AbstractResponse rsp) { boolean bool = false; if (req.getUserType() <= 0) { rsp.setResultCode(NumberUtils.toInt(bundle.getString("code_user_type"))); rsp.setResultMsg(bundle.getString("msg_user_type")); } else { bool = true; } return bool; } /** * 检查content_code * * @param req * @param rsp * @return */ public static boolean checkContentCodeParam(ContentRequest req, AbstractResponse rsp) { boolean bool = false; if (StringUtils.isBlank(req.getContentCode())) { rsp.setResultCode(NumberUtils.toInt(bundle.getString("code_content_code_not_exists"))); rsp.setResultMsg(bundle.getString("msg_content_code_not_exists")); } else { bool = true; } return bool; } /** * 检查内容类型 * * @param req * @param rsp * @return */ public static boolean checkObjectTypeParam(ContentRequest req, AbstractResponse rsp) { boolean bool = false; if (req.getObjectType() <= 0) { rsp.setResultCode(NumberUtils.toInt(bundle.getString("code_object_type_not_exists"))); rsp.setResultMsg(bundle.getString("msg_object_type_not_exists")); } else { bool = true; } return bool; } /** * 检查内容类型 * * @param req * @param rsp * @return */ public static boolean checkProductCodeParam(ProductRequest req, AbstractResponse rsp) { boolean bool = false; if (checkSubInfoList(req.getSubInfoList())) { rsp.setResultCode(NumberUtils.toInt(bundle.getString("code_sub_info_illgal"))); rsp.setResultMsg(bundle.getString("msg_product_code_not_exists")); } else { bool = true; } return bool; } public static boolean checkSubInfoList(SubInfo[] subInfos) { boolean bool = true; if (subInfos != null && subInfos.length > 0) { for (SubInfo subinfo : subInfos) { if (StringUtils.isBlank(subinfo.getProductID())) { bool = false; } } } else { bool = false; } return bool; } }
相关推荐
【标题】"Axis2示例工程"是一个展示如何在Java环境中使用Axis2和Spring框架来构建Web服务的应用实例。这个项目旨在帮助开发者理解和实践WebService的创建、部署以及调用过程,特别是结合了流行的Spring框架,使得...
本文将深入探讨如何使用Axis2发布Web服务,并通过一个名为"MyWebservice"的示例进行详细讲解。 首先,让我们了解Web服务的基本概念。Web服务是一种通过互联网交换结构化信息的应用程序接口(API)。它使用标准的XML...
标题中的“webservice axis开发示例”是指使用Apache Axis框架创建和使用Web服务的实践案例。Apache Axis提供了一套工具和服务,简化了Web服务开发过程,包括编译WSDL(Web服务描述语言)文件为Java代码、生成客户端...
通过以上步骤,我们完成了基于 Axis2 的 Web Services 开发环境的搭建,并成功创建了一个简单的 Web Service 示例。此过程不仅涵盖了软件开发的基础环境配置,还涉及了 Web Services 的具体开发和部署流程。对于初学...
**四、使用Axis2 1.6.2开发示例:** 1. **创建服务类:** 定义一个简单的Java类,实现业务逻辑。 2. **生成服务描述:** 使用Axis2工具生成对应的WSDL文件,描述服务接口和操作。 3. **打包服务:** 创建服务配置...
Axis是Apache软件基金会开发的一个开放源代码的Web服务框架,主要用于构建和部署Web服务。它提供了在Java平台上创建和使用Web服务的能力。本示例将详细介绍如何使用Axis创建和使用一个简单的Web服务。 首先,我们...
Axis2_WebService_开发指南详细介绍了如何使用Axis2开发WebService。 首先,在进行Axis2的准备工作时,需要下载Axis2的相关jar包,这些依赖包可以在Axis2的官方网站上找到。截至文档提供的信息,最新的版本是1.5.4...
2. **添加Axis依赖**:在`pom.xml`文件中,我们需要添加Axis的相关依赖。这包括`axis`, `axis-saaj`, 和 `axis-wsdl4j`等。 3. **创建Web服务接口**:定义一个Java接口,这个接口代表我们的Web服务。接口中定义了将...
【标题】:“Axis1的示例与Web服务开发手册” 【描述】中提到的“Axis1的示例”是一个实际的应用实例,它展示了如何利用Apache Axis1框架来创建和使用Web服务。Apache Axis1是一个开源的Java库,专门用于构建和部署...
Axis2是Apache软件基金会开发的一个Web服务框架,专为高性能和可扩展性而设计。本文将深入探讨如何使用Axis2发布一个简单的Web服务,并提供相关知识点。 1. **Web服务基础**: Web服务基于开放标准,如SOAP...
本文将详细介绍如何使用Eclipse集成开发环境和AXIS2框架创建并调用WebService。首先,我们需要准备以下基础工具: 1. Eclipse IDE:这是一个强大的Java开发平台,支持多种开发任务,包括Web服务的开发和调试。 2. ...
Apache Axis2是Apache软件基金会开发的一个Web服务引擎,它提供了高效且灵活的Web服务解决方案。 **Web服务**是一种在互联网上不同系统间交换数据的方式,它允许应用程序之间通过标准协议进行通信。Web服务通常使用...
这些文件可能包含上述提到的API参考、教程和示例代码,它们是学习和开发基于Axis或Axis2的Web服务不可或缺的资源。通过仔细阅读这些文档,开发者可以掌握如何使用Axis或Axis2来创建符合WS-I标准、高性能的Web服务,...
### Axis与Axis2在WSDL2Java工具中的发布差异 #### 概述 ...这使得Axis2在现代Web服务开发中成为了一个更受欢迎的选择。开发者可以根据自己的具体需求选择最适合的工具来进行Web服务的构建和部署。