webservice axi2 远程服务端接口调用

来源:互联网 发布:百度贴吧获取数据失败 编辑:程序博客网 时间:2024/05/18 01:37
/**
     * WebServices客户端方法
     *
     * @param url       webService url
     * @param namespace 命名空间
     * @param param     参数
     * @param method    方法
     * @return
     */
    public static String axi2ClientUtil(String url, String namespace, Object param[], String method) {
        String xml="";
        try {
            RPCServiceClient serviceClient = new RPCServiceClient();
            EndpointReference endpointReference = new EndpointReference(url);
            Options options = serviceClient.getOptions();
            options.setTo(endpointReference);
            options.setAction("urn:" + method);
            QName qName = new QName(namespace, method);
            //Class[] returnTypes = new Class[]{String.class};
            OMElement element = serviceClient.invokeBlocking(qName, param);
            xml=element.getFirstElement().getText();
        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
        }
        return xml;

    }



2.

public static void main(String[] args) throws Exception{
String url=“”;

       String namesqpace="";

       String method="";
    Service service=new Service();
    Call call=(Call)service.createCall();
    call.setTargetEndpointAddress(url);
    call.setOperationName(new QName(namesqpace,method));
    call.addParameter("spid",XMLType.XSD_STRING,ParameterMode.IN);
    call.addParameter("username",XMLType.XSD_STRING,ParameterMode.IN);
    call.addParameter("password",XMLType.XSD_STRING,ParameterMode.IN);
    call.addParameter("xml",XMLType.XSD_STRING,ParameterMode.IN);
    call.setReturnType(XMLType.XSD_STRING);
    //String upload="";
    String xml="<datapacket wsid=\"EIS_PERSON_OUT\" errcode=\"\" errmsg=\"\"><rowdata>";
        xml +="<row UORGANID=" +"\""+"nanning"+"\" "+
        "PERSONID="+"\""+"hqks01"+"\""+ " PERSONNAME=\"\" STARTDATE=\"\" ENDDATE=\"\" MEMO=\"\" />";
        xml+="</rowdata></datapacket>";
    String download = (String)call.invoke(new Object[]{"HQKS01","rfid01","123",xml});

    System.out.println(download);


}



0 0
原创粉丝点击