Axis2调用异常,请大家帮忙,谢谢

李林古 发布于 2012/01/10 11:39
阅读 1K+
收藏 0

Axis2调用异常,异常信息:

Exception in thread "main" java.lang.IllegalArgumentException: The MessageContext does not have an associated SOAPFault.
 at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:455)
 at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:371)
 at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
 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:540)
 at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:521)
 at org.apache.axis2.rpc.client.RPCServiceClient.invokeBlocking(RPCServiceClient.java:102)
 at com.tisson.client.WsClientCall.main(WsClientCall.java:92)

 

客户端调用代码如下(服务端接口服务无问题):

public class WsClientCall {
 private static Logger log = LoggerFactory.getLog(WsClientCall.class);
 
 public static void main(String[] args) throws AxisFault {  
  log.info("=========Axis2调用开始==========");
  log.info("使用RPCClient方式调用");
  //1、使用RPCClient调用
  RPCServiceClient client = new RPCServiceClient();
  Options option = client.getOptions();
  String wsUrl = "http://xxx.xxx.xxx.xxx:9002/ESB/ProxySvc/ESBCRMWSSERV?wsdl";//调用的URL
  EndpointReference ref = new EndpointReference(wsUrl);
  option.setTo(ref);
  /*
   * QName 参数说明
   * 1、命名空间,访问http://172.16.27.63:7001/Axis2Test/services/TestService?wsdl显示的xml中的
   *   targetNamespace="http://service.server.tisson.com",services.xml中ServiceClass的包路径倒过来
   * 2、调用Service的方法名
   */
  String nameSpace = "mboss-esb"; 

  String methodName = "call"; 
  QName qName = new QName(nameSpace,methodName);
  
  /*
   * 设置SOAP包头验证信息
   */
  SOAP11Factory factory = new SOAP11Factory();  
  OMNamespace SecurityElementNamespace = factory.createOMNamespace(
    "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd","Security");
  OMElement usernameTokenEl = factory.createOMElement("UsernameToken",
                SecurityElementNamespace);
        OMElement usernameEl = factory.createOMElement("username",
                SecurityElementNamespace);
        OMElement passwordEl = factory.createOMElement("password",
                SecurityElementNamespace);
        passwordEl.addAttribute(factory.createOMAttribute("Type",null,
          "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"));
        usernameEl.setText("10000");
        passwordEl.setText("b5245442");
        usernameTokenEl.addChild(usernameEl);
        usernameTokenEl.addChild(passwordEl);
        SOAPHeaderBlockImpl block = new SOAP11HeaderBlockImpl("Security",SecurityElementNamespace,factory);
        block.addChild(usernameTokenEl);
       
        client.addHeader(block);
       
  String paramIn =
   "<?xml version=\"1.0\" encoding=\"GB2312\"?>"
   +"<Business><BaseInfo><ReqCode>100002018825163</ReqCode><SysCode>10000</SysCode><SysPwd>b5r432df</SysPwd><SourceCode>1</SourceCode><TargetCode>200</TargetCode><FuncCode>SUBS643</FuncCode><Sync>1</Sync><Version>2.0</Version></BaseInfo><SendData><inputdatas><controlinfo><staffid>ESB10000</staffid><password>011216E5F5897AD0F44BADCDSWG3GGDBA7C0</password><posttype>200</posttype></controlinfo>" +
    "<params sets=\"1\"><param cols=\"4\" rows=\"1\" set_id=\"101\"><row rownum=\"1\"><col colnum=\"1\" param_id=\"1643001\" param_name=\"验证类型\">11</col><col colnum=\"2\" param_id=\"1643002\" param_name=\"标志类型\">2</col><col colnum=\"3\" param_id=\"1643003\" param_name=\"标志值\">87654500</col><col colnum=\"4\" param_id=\"1643004\" param_name=\"密码\">xxxxxx</col></row></param></params></inputdatas></SendData></Business>";
  //"Axis2调用";
  Object[] oAddArgs = new  Object[] {paramIn};   //传入参数
  Class[] response = new  Class[] {String.class};   //返回值类型
  
  /*
   * invokeBlocking 参数说明
   * 1、命名空间 QName
   * 2、传入参数 oAddArgs
   * 3、返回值类型 returnTypes
   */
  String result = (String) client.invokeBlocking(qName, oAddArgs, response)[0];
  log.info(result);
  log.info("=========Axis2调用结束==========");
 }

加载中
返回顶部
顶部