package client;import javax.xml.namespace.QName;import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;public class TestClient {
public static void main(String[] args) throws Exception {
/************/
String url = "接口地址";
String username = "用户名";
String password = "密码";
String domain = "域名";
String method = "getInfo";
String reqArg = "一串请求的xml";
/************/

// 使用 RPC 方式调用 WebService
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();

options.setAction(domain+method);

// 指定调用 WebService 的 URL
EndpointReference targetEPR = new EndpointReference(url);
options.setTo(targetEPR);

// 指定 getGreeting 方法的参数值
Object[] opAddEntryArgs = new Object[] { reqArg };

// 指定 getGreeting 方法返回值的数据类型的 Class 对象
Class[] classes = new Class[] { String.class };

// 指定要调用的 getGreeting 方法及 WSDL 文件的命名空间
QName opAddEntry = new QName(domain,method);

// 调用 getGreeting 方法并输出该方法的返回值
System.out.println(serviceClient.invokeBlocking(opAddEntry,opAddEntryArgs, classes)[0]);
}
}我调用自己建的接口时不出错,而调用别人的接口时就出了这错了:
Exception in thread "main" org.apache.axis2.AxisFault: 服务器无法处理请求。 --> 值不能为空。
参数名: s
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:548)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528)
at org.apache.axis2.rpc.client.RPCServiceClient.invokeBlocking(RPCServiceClient.java:102)
at client.TestClient.main(TestClient.java:63)

解决方案 »

  1.   

    请问题reqArg 应该是什么样的XML字符串?
      

  2.   

    值不能为空,说明有一些参数传少了或不够,可以使用浏览器访问试一下。
    http://www.stc.***/dataService/services/DataexchangeService?wsdlhttp://www.stc.***/dataService/services/DataexchangeService/方法?参数1=&参数2=。。
      

  3.   

    楼主在这行中去找,at client.TestClient.main(TestClient.java:63)
    看是否有个参数名为“s”的,它的值是否是空
      

  4.   

    看不出 哪里出了问题修改成这样可以获得到结果   ServiceClient sender = new ServiceClient();
             Options option = new Options(); 
     option.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
     option.setAction("http://WebXml.com.cn/getWeatherbyCityName");
     EndpointReference epfs = new EndpointReference(address);
     option.setTransportInProtocol(Constants.TRANSPORT_HTTP);
     option.setTo(epfs);
          sender.setOptions(option);
          
         OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://WebXml.com.cn/", "");
    OMElement data = fac.createOMElement("getWeatherbyCityName", omNs);
    OMElement inner = fac.createOMElement("theCityName", omNs);
    inner.setText("长沙");
    data.addChild(inner);
    OMElement result = sender.sendReceive(data);
    System.out.println(result);
      

  5.   

    option.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);是什么意思呀?