实体类:
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; } }
相关推荐
标题中的“webservice axis开发示例”是指使用Apache Axis框架创建和使用Web服务的实践案例。Apache Axis提供了一套工具和服务,简化了Web服务开发过程,包括编译WSDL(Web服务描述语言)文件为Java代码、生成客户端...
Axis是Apache软件基金会开发的一个开放源代码的Web服务框架,主要用于构建和部署Web服务。它提供了在Java平台上创建和使用Web服务的能力。本示例将详细介绍如何使用Axis创建和使用一个简单的Web服务。 首先,我们...
【标题】:“Axis1的示例与Web服务开发手册” 【描述】中提到的“Axis1的示例”是一个实际的应用实例,它展示了如何利用Apache Axis1框架来创建和使用Web服务。Apache Axis1是一个开源的Java库,专门用于构建和部署...
文将介绍如何使用Tomcat5.0和Apache Axis2开发、部署及测试一个简单的Web Service应用
借鉴网上的资源,弄了一个SpringBoot开发WebService之Axis示例。
这个"Axis2例子Demo"旨在帮助开发者快速理解和应用Axis2框架,解决他们在尝试 Axis2 示例时可能遇到的问题。 **一、Axis2简介** Axis2是基于SOAP(简单对象访问协议)的Web服务框架,它构建在AXIOM(抽象XML信息...
【S2Axis2实例详解】 在Java世界中,Web服务的开发是一项常见的任务,而Seasar2 Axis2项目提供了一种...在实际操作中,结合`s2axis2-examples`中的示例,可以进一步加深对这两个框架整合使用的理解,提高开发效率。
它通常包含Axis2的核心库、模块、示例、文档以及必要的配置文件。当你下载这个zip文件,你可以解压后在本地环境中搭建和运行Axis2服务。通过这个文件,开发者可以进行开发和测试Web服务,因为它提供了完整的Axis2...
"AnyType"在AXIS2中指的是可以处理任何类型的XML数据的能力,它允许开发人员处理那些在WSDL(Web服务描述语言)中没有明确指定类型的数据。在AXIS2中实现AnyType的主要目标是提供灵活性,使得Web服务能够接收和返回...
这篇文档详细介绍了如何使用Axis2在基于Eclipse的MyEclipse环境中开发Web服务,特别是针对"SayHello"这个简单示例的步骤。 首先,开发者需要准备必要的软件环境,包括Tomcat 5.5作为Web容器,Axis2 API的2.1.1版本...
Axis2是Apache软件基金会开发的一款基于Java的Web服务框架,它是Apache SOAP(Simple Object Access Protocol)项目的下一代产品,专门用于构建高性能、可扩展的Web服务。这个“axis2学习资料”压缩包很可能是包含了...
Axis1.4 是一个开源的 SOAP(简单对象访问协议)服务框架,用于构建和部署 Web ...通过这个示例,你可以了解 Axis1.4 如何帮助开发者快速地创建、部署和管理 Web 服务,从而更好地理解和掌握 Web 服务开发的基本流程。
Axis2是Apache软件基金会开发的一个开放源代码Web服务引擎,它是基于Java平台的,专门用于构建和部署Web服务。下面将详细阐述Axis2的相关知识点: 1. **什么是Axis2**: Axis2是第二代Apache Axis,它是处理SOAP...
Axis2 WebService 开发指南 Axis2 是一个基于 Java 的开源 WebService 框架,具有高效、灵活、可扩展等特点。以下是对 Axis2 WebService 开发指南的知识点总结: 1. 环境准备: Axis2 的开发需要下载相关的 jar ...
本篇将深入讲解标题为"Axis2Demo"的示例,它展示了Axis2在客户端和服务端的应用。 ### 1. Axis2简介 Axis2是基于SOAP(Simple Object Access Protocol)的,用于处理Web服务的底层通信。它基于AXIOM(Abstract XML...
- "web_service技术--axis2在eclipse下开发指南"、"Axis2介绍和例子"、"axis2新手教程实例"等文档,详细介绍了在Eclipse环境下使用Axis2开发和部署Web Service的步骤和示例。 通过这些资料,开发者可以深入了解...
axis2实现传递list格式的资源包 用户解压此压缩包中的jar到资源路径中即可实现axis2传递list格式数据
总结起来,Axis2提供了多样化的Web服务实现方式,适应不同开发需求。选择合适的方式取决于项目的规模、性能要求以及团队对XML处理的熟悉程度。理解并掌握这些技术,对于提升Java Web服务开发的效率和质量具有重要...
1. "axis2_WebService_开发指南.docx" - 这可能是文档形式的详细教程,包含了步骤说明、代码示例和可能的疑难解答,帮助开发者逐步理解并实践Axis2 Web服务开发。 2. "Axis2教程.pdf" - 另一份可能更深入或者从不同...
通过这个示例,读者可以了解从头到尾构建一个基于Axis2的Web服务端的完整过程,并掌握如何将Spring框架的优势引入到服务端的开发中。 总结,基于Axis2构建服务端涉及的主要知识点包括Axis2的架构和特性、Web服务的...