Browse Source

添加webservice

lingfeng 9 years ago
parent
commit
abaf9fc156

+ 26 - 20
Hos-Resource-Rest/pom.xml

@ -206,26 +206,32 @@
            <artifactId>xom</artifactId>
            <version>1.1</version>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>org.apache.axis2</groupId>-->
            <!--<artifactId>axis2</artifactId>-->
            <!--<version>1.6.3</version>-->
        <!--</dependency>-->
        <!--<dependency>-->
            <!--<groupId>org.apache.axis2</groupId>-->
            <!--<artifactId>axis2-adb</artifactId>-->
            <!--<version>1.6.3</version>-->
        <!--</dependency>-->
        <!--<dependency>-->
            <!--<groupId>org.apache.axis2</groupId>-->
            <!--<artifactId>axis2-kernel</artifactId>-->
            <!--<version>1.6.3</version>-->
        <!--</dependency>-->
        <!--<dependency>-->
            <!--<groupId>org.apache.axis2</groupId>-->
            <!--<artifactId>org.apache.axis2.osgi</artifactId>-->
            <!--<version>1.6.3</version>-->
        <!--</dependency>-->
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2</artifactId>
            <version>1.6.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-adb</artifactId>
            <version>1.6.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-kernel</artifactId>
            <version>1.6.3</version>
            <exclusions>
                <exclusion>
                    <artifactId>XmlSchema</artifactId>
                    <groupId>org.apache.ws.commons.schema</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>org.apache.axis2.osgi</artifactId>
            <version>1.6.3</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>

+ 24 - 20
Hos-Resource-Rest/src/main/java/com/yihu/hos/gateway/util/RPCUtil.java

@ -3,7 +3,11 @@ package com.yihu.hos.gateway.util;
import com.yihu.hos.config.Config;
import com.yihu.wsgw.api.ServiceBus;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
import javax.xml.namespace.QName;
/**
 * Created by Administrator on 2016/4/18.
 */
@ -26,26 +30,26 @@ public class RPCUtil {
     * @param inputValuetype
     * @return
     */
//    public static String getObjectByAxis2CallClient(String webServiceAddr, String webserviceNamespace, String webServiceMethod,
//                                                    Object[] inputValues, Class[] inputValuetype) {
//
//        try {
//            //新建RPC服务客户端
//            RPCServiceClient serviceClient = new RPCServiceClient();
//            Options options = serviceClient.getOptions();
//            //设置URL
//            EndpointReference targetEPR = new EndpointReference(webServiceAddr);
//            options.setTo(targetEPR);
//            //设置参数的类型
//            //设置namespace和方法名
//            QName opAddEntry = new QName(webserviceNamespace, webServiceMethod);
//            //数组的第一个值为返回值
//            return (String) (serviceClient.invokeBlocking(opAddEntry, inputValues, inputValuetype))[0];
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return "";
//    }
    public static String getObjectByAxis2CallClient(String webServiceAddr, String webserviceNamespace, String webServiceMethod,
                                                    Object[] inputValues, Class[] inputValuetype) {
        try {
            //新建RPC服务客户端
            RPCServiceClient serviceClient = new RPCServiceClient();
            Options options = serviceClient.getOptions();
            //设置URL
            EndpointReference targetEPR = new EndpointReference(webServiceAddr);
            options.setTo(targetEPR);
            //设置参数的类型
            //设置namespace和方法名
            QName opAddEntry = new QName(webserviceNamespace, webServiceMethod);
            //数组的第一个值为返回值
            return (String) (serviceClient.invokeBlocking(opAddEntry, inputValues, inputValuetype))[0];
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
    /*
    public static void main(String[] args) throws Exception {
        String apiName = "report.ReportWs.GetReportList";