日期:2014-05-18  浏览次数:20697 次

请教webservice接口的问题!急急急!各位大侠进来帮忙看看
我现在是java里面调用别人做的webservice接口,别的公司用的是.net做的接口,我这边java来调用,调用的方法如下:
Java code
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;
    }


调用完了结果发现那边返回报错:值不能为空。参数名: s
试了各种办法都没有结果,都解决不了问题,不知道是我这边调用方式有问题还是那边接口有问题,我这边传的参数是一个xml形式的String类型的参数,我自己这边打印出来是完整的xml格式的内容,但是通过接口传过去就变为空了,不知道是什么原因,各位大侠帮帮忙,很急的!!

------解决方案--------------------
http://blog.csdn.net/madun/article/details/3777434
看下这个

貌似java 调用webserveice的时候 不用addparam尤其是 参数本身就是string的时候
------解决方案--------------------
...路过
------解决方案--------------------
建议你使用eclipse集成的axis去生成client代码,需要wsdl,方便调用。
------解决方案--------------------
帮顶你好哈罗
------解决方案--------------------
先用axis的工具生成调用工具类,然后去调用就没有问题了