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进行调用,看控制台是否能收到数据,收到说明发布成功。

 

posted @ 2020-03-30 17:34  iHADream  阅读(348)  评论(0编辑  收藏  举报