解决方案 »

  1.   

    [Ljava.lang.String;@d9edbenihao 这个结果不代表对象中有正确的值。只代表有这个对象
      

  2.   

    axis2的serviceClient调用应该不是invokeBlocking方法,是sendReceive。api说明他给出四种访问方法,最简单的是get post方法访问。
      

  3.   

    如果用axis2,应该是这样调用的。 String soapBindingAddress = "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?WSDL";
    ServiceClient sender = new ServiceClient();
    EndpointReference endpointReference = new EndpointReference(
    soapBindingAddress);
    Options options = new Options();
    options.setAction("http://WebXml.com.cn/getRegionProvince");
    options.setTo(endpointReference);
    sender.setOptions(options);
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://WebXml.com.cn/",
    "getRegionProvince");
    OMElement data = fac.createOMElement("getRegionProvince", omNs);
    OMElement ele = sender.sendReceive(data);
    System.out.println(ele.toString());
      

  4.   

    [Ljava.lang.String;@d9edbenihao是有数组对象,而非数组中有值
      

  5.   


    哦!还有这种方法?我去试试。
    我用的是RPC的调用。刚开始学,纯小白,好多都不明白。谢谢你^_^
      

  6.   


    那么strArray.length=1是为什么呢?
      

  7.   

    RPCServiceClient应该是这样的。
    RPCServiceClient client = new RPCServiceClient();
    Options options = client.getOptions();
    EndpointReference target = new EndpointReference(
    "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?WSDL");
    options.setTo(target);
    options.setAction("http://WebXml.com.cn/getRegionProvince");
    QName opName = new QName("http://WebXml.com.cn/", "getRegionProvince");
    OMElement response = client.invokeBlocking(opName, new Object[] {});
    System.out.println(response);
      

  8.   

    亲的给的两段代码我都试过了,都好用^_^
    很奇怪,那么我自己写的差在哪里了呢?
    对照了一下我原来的代码,差别大概只有我调用的是三个输入参数的invokeBlocking方法,返回值是一个object,而非OMELement。是这里调用不当导致无法取得结果么?
      

  9.   

    这是我的代码(写得太乱真不好意思拿出来~~~~(>_<)~~~~ ) public static Object sampleuse(String serviceAddress,String wsdlNameSpace,String operationName,Object[] inputArgs,String outputType) throws Exception {

    //为了测试方便,写成了static方法

    try{
    RPCServiceClient serviceClient=new RPCServiceClient();
    //指定调用webservice的url
    EndpointReference targetEPR=new EndpointReference(serviceAddress);
    Options options=serviceClient.getOptions();
    options.setTo(targetEPR);
    options.setAction("http://WebXml.com.cn/getRegionProvince");//这个应该是wsdlNameSpace/operationName
    Object[] opAddEntryArgs=inputArgs; Class[] classes=new Class[]{String[].class};


    QName opAddEntry=new QName(wsdlNameSpace,operationName); Object[] response=null;
    if(classes.length==0){
    serviceClient.invokeRobust(opAddEntry, classes);
    }
    else{
    response=serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, classes);
    System.out.println((String[])response[0]+"nihao");
    return response[0];

    } }catch(AxisFault e){
    e.printStackTrace();
    }

    return null;
    }


    public static void main(String[] args) throws Exception{
    String serviceAddress="http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?WSDL";
    String wsdlNameSpace="http://WebXml.com.cn/";
    String operationName="getRegionProvince";
    Object[] inputArgs=new Object[]{};

    Object response2=sampleuse(serviceAddress,wsdlNameSpace,operationName,inputArgs,null);
    String[] strArray=(String[])response2;
    String s=null;
    System.out.println("strArray.length is :"+strArray.length);
    for(int i=0;i<strArray.length;i++){

    System.out.println(strArray[i]);

    } }
      

  10.   

    axis 1的 看看String url = "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx";
    String nameSpace = "http://WebXml.com.cn/";
    String method = "getRegionProvince";
    Service service = new Service();
    Call call;
    call = (Call) service.createCall();
    call.setTargetEndpointAddress(new java.net.URL(url));
    call.setOperationName(new QName(nameSpace, method));
    call.setUseSOAPAction(true);
    call.setSOAPActionURI(nameSpace + method);
    call.setReturnClass(String[].class); 
    String[] res = (String[]) call.invoke(new Object[] { });
    for (String string : res) {
    System.out.println(string);
    }
      

  11.   

    亲的给的两段代码我都试过了,都好用^_^
    很奇怪,那么我自己写的差在哪里了呢?
    对照了一下我原来的代码,差别大概只有我调用的是三个输入参数的invokeBlocking方法,返回值是一个object,而非OMELement。是这里调用不当导致无法取得结果么?我的妈呀又出错了。死的心都有!调用的还是同一个服务,但是不同的方法,有一个输入参数,返回一个字符串数组。结果!
    xception in thread "main" org.apache.axis2.AxisFault: 服务器无法处理请求。 ---> 值不能为空。
    参数名: input
    at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
    at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
    at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:555)
    at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:531)
    at org.apache.axis2.rpc.client.RPCServiceClient.invokeBlocking(RPCServiceClient.java:76)
    at client.SimpleUseThree.getResponse(SimpleUseThree.java:89)
    at client.SimpleUseThree.main(SimpleUseThree.java:133)调用的方法是getSupportCityString,输入参数为311202
      

  12.   

    明明只有一个输入参数呀!而且输入参数也不叫input啊!!!