axis

http://10.15.22.28/itfmgr/services/ITaxManagement?wsdl
package com.isoftstone.core.service.impl;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;
import org.apache.axis.encoding.XMLType;

import com.isoftstone.core.service.intf.ServiceOfStringPara;
/**
 * 海闻发票验证接口
 * @author 金剑波
 * @url http://www.cnblogs.com/whatlonelytear/p/5152121.html
 */
public class ValidateInvoiceImpl2   {

    static void validateInvoice() {
        try {
            // 1.创建service对象,通过axis自带的类创建
            org.apache.axis.client.Service service = new org.apache.axis.client.Service();

            // 2.创建url对象
            String wsdlUrl = "71xxxxxxxxxxxxxxxxxx";// 请求服务的URL
            URL url = new URL(wsdlUrl);// 通过URL类的构造方法传入wsdlUrl地址创建URL对象

            // 2.创建服务方法的调用者对象call,设置call对象的属性
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress(url);// 给call对象设置请求的URL属性
            String serviceName = "validateInvoice";
            call.setOperationName(serviceName);// 给call对象设置调用方法名属性
            // call.addParameter("groupNo", XMLType.XSD_LONG,
            // ParameterMode.IN);// 给call对象设置方法的参数名、参数类型、参数模式
            call.addParameter("invoiceNumber", XMLType.SOAP_STRING,
                    ParameterMode.IN);
            call.addParameter("invoiceCode", XMLType.SOAP_STRING,
                    ParameterMode.IN);
            call.addParameter("issueDate", XMLType.SOAP_STRING,
                    ParameterMode.IN);
            call.addParameter("totalInTax", XMLType.SOAP_STRING,
                    ParameterMode.IN);
            call.addParameter("tax_num", XMLType.SOAP_STRING, ParameterMode.IN);
            call.setReturnType(XMLType.SOAP_STRING);// 设置调用方法的返回值类型

            // 4.通过invoke方法调用webservice
            // long groupNo = 2100000014L;
            String invoiceNumber = "00020009";
            String invoiceCode = "115000000000";
            String issueDate = "2016-05-23";
            String totalInTax = "74.50";
            String tax_num = "500080000000020";
            String res = (String) call.invoke(new Object[] { invoiceNumber,
                    invoiceCode, issueDate, totalInTax, tax_num });// 调用服务方法
            System.out.println(res);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (ServiceException e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        validateInvoice();
    }
}
04-30 05:51