zoukankan      html  css  js  c++  java
  • axis2添加接口过程

    1.首先写好xsd,xsd主要包括接受内容的类和返回内容的类;

    2.根据xsd生成所用的接受类,并放在相应的包下;

    3.新建一个controller类,添加@endpoint注解,

    具体方法上添加@PayloadRoot(localPart = "transferRequest", namespace = TARGET_NAMESPACE),其中localpart为xsd中请求类的名称,namespace为自己定义的命名空间,      
    具体方法编写时要写成这样,public @ResponsePayload TransferResponse transferIncomingInformation(@RequestPayload TransferRequest request),需要分别在Response返回值和Request请求值前分别添加@ResponsePayload@RequestPayload注解;

    @Endpoint
    public class WebserviceController {
        
        /**
         * axis2接口测试
         * 
         * @param request
         * @return
         */
        @PayloadRoot(localPart = "transferRequest", namespace = "http://")
        public @ResponsePayload TransferCompanyResponse transferCompany(@RequestPayload TransferCompanyRequest request) {

      System.out.println("---------测试接口已收到内容,内容为:"+ request.toString() +"-------------");

      }
    }

    4.在一个配置文件中,发布接口,配置文件如下所示,

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
        xmlns:sws="http://www.springframework.org/schema/web-services"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                                http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
                                http://www.springframework.org/schema/web-services
                                http://www.springframework.org/schema/web-services/web-services-2.0.xsd
                                http://www.springframework.org/schema/context
                                http://www.springframework.org/schema/context/spring-context-3.2.xsd">
    
        <context:component-scan
            base-package="com.wulianb.sws.services,com.wulianb.web.sws.controller" >
            <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/> 
            </context:component-scan>

    <sws:dynamic-wsdl id="lgincomingInformation" portTypeName="lgincomingInformation" locationUri="http://test.hbisscm.com/wulianb/ws"><sws:xsd location="/WEB-INF/schemas/laogang/incomingInformation.xsd"/></sws:dynamic-wsdl> </beans>

    5.启动项目,根据配置文件发布的地址,访问他的wsdl,访问的通用soapui进行调用,看控制台是否能收到数据,收到说明发布成功。

    金无足赤,人无完人,若有文章什么问题欢迎各位批评指正,共同交流,共同进步。 另,人过留名,雁过留声,少侠觉得还行的话留下个赞吧!:)
  • 相关阅读:
    v-date
    文字在图片上
    v-生命周期
    彭博接口分类
    如何指定vim 的查找是从上往下还是从下往上[z]
    查看linux版本
    git web找不到new project解决方法
    比特币运行原理[z]
    [Z]haproxy+keepalived高可用群集
    blockchain good article
  • 原文地址:https://www.cnblogs.com/thePeaceOftheLord/p/11926037.html
Copyright © 2011-2022 走看看