日期:2014-05-18 浏览次数:20718 次
public String sendCardToGIS(String method,String xmlparam){ String result = "0"; try{ serviceClient = new Service( ); callClient = (Call) serviceClient.createCall( ); //GIS的webservice地址 callClient.setTargetEndpointAddress( new java.net.URL("http://134.224.1.121/JKsite091402/TelAssetWebService.asmx") ); //GIS的webservice方法 callClient.setOperationName(new QName("http://tempuri.org/", method)); callClient.addParameter(new QName("http://tempuri.org/","xmlparam"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN); callClient.setUseSOAPAction(true); callClient.setSOAPActionURI("http://tempuri.org/CardBack"); callClient.setReturnType(org.apache.axis.encoding.XMLType.SOAP_STRING); String xmlResult = (String) callClient.invoke(new Object[]{xmlparam}); System.out.println("传的参数为:"+ xmlparam ); System.out.println("返回的结果为:" +xmlResult ); //解析调用返回的结果XML字符串 TIFResponse tifResponse=IFResponseUtility.buildEntityString( xmlResult ); result=tifResponse.getIfResult( );//这个result是对方返回的xml中的一个节点中的值 if(!result.equals( "0" )) { result="1"; if(tifResponse.getIfError( )!=null&&!tifResponse.getIfError( ).equals( "" )) logger.error("调用GIS接口时发生错误:"+tifResponse.getIfError( )); if(tifResponse.getIfErrorStack( )!=null&&!tifResponse.getIfErrorStack( ).equals( "" )) logger.error("调用GIS接口时发生错误异常:"+tifResponse.getIfErrorStack( )); } }catch ( Exception e ){ System.out.println( "调用失败!" ); e.printStackTrace( ); logger.error( e.getCause( ).getMessage( )); if( e.getCause( ).getMessage( ).equals("Connection timed out: connect")){ return "2"; } return "1"; } return result; }