【问题标题】:org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement underTimelyRenewalorg.apache.axis2.AxisFault:org.apache.axis2.databinding.ADBException:Unexpected subelement underTimelyRenewal
【发布时间】:2012-10-24 04:07:42
【问题描述】:

在访问轴 2 网络服务之前,我遇到了以下异常。

org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement underTimelyRenewal

我无法在本地的 tomcat 或在 Weblogic 中运行的 DEV 环境中重现相同的问题。它只发生在 Weblogic 11g 上运行的 1 个环境中。这让人觉得我在那个环境中缺少一些配置,我不确定它是什么。非常感谢您对此提供任何帮助。

这是调用网络服务的代码。

public  com.ibs.accouting.employeeVerificationResponse getEmployeeVerificationRequest(

                        com.ibs.accounting.EmployeeVerificationRequest employeeVerificationRequest108)


                throws java.rmi.RemoteException

                {
          org.apache.axis2.context.MessageContext _messageContext = null;
          try{
           org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[5].getName());
          _operationClient.getOptions().setAction("http://ibs.com/accounting/WBLEmployeeVerificationRequest");
          _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);



              addPropertyToOperationClient(_operationClient,org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,"&");


          // create a message context
          _messageContext = new org.apache.axis2.context.MessageContext();



          // create SOAP envelope with that payload
          org.apache.axiom.soap.SOAPEnvelope env = null;


                                                env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
                                                employeeVerificationRequest108,
                                                optimizeContent(new javax.xml.namespace.QName("http://ibs.com/accounting",
                                                "getEmployeeVerificationRequest")));

    //adding SOAP soap_headers
     _serviceClient.addHeadersToEnvelope(env);
    // set the message context with that soap envelope
    _messageContext.setEnvelope(env);

    // add the message contxt to the operation client
    _operationClient.addMessageContext(_messageContext);

    //execute the operation client
    _operationClient.execute(true);


           org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient.getMessageContext(
                                       org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope();


                            java.lang.Object object = fromOM(
                                         _returnEnv.getBody().getFirstElement() ,
                                         com.ibs.accounting.EmployeeVerificationResponse.class,
                                          getEnvelopeNamespaces(_returnEnv));


                                    return (com.ibs.accounting.EmployeeVerificationResponse)object;

     }catch(org.apache.axis2.AxisFault f){

        org.apache.axiom.om.OMElement faultElt = f.getDetail();
        if (faultElt!=null){
            if (faultExceptionNameMap.containsKey(faultElt.getQName())){
                //make the fault by reflection
                try{
                    java.lang.String exceptionClassName = (java.lang.String)faultExceptionClassNameMap.get(faultElt.getQName());
                    java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName);
                    java.lang.Exception ex=
                            (java.lang.Exception) exceptionClass.newInstance();
                    //message class
                    java.lang.String messageClassName = (java.lang.String)faultMessageMap.get(faultElt.getQName());
                    java.lang.Class messageClass = java.lang.Class.forName(messageClassName);
                    java.lang.Object messageObject = fromOM(faultElt,messageClass,null);
                    java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage",
                               new java.lang.Class[]{messageClass});
                    m.invoke(ex,new java.lang.Object[]{messageObject});


                    throw new java.rmi.RemoteException(ex.getMessage(), ex);
                }catch(java.lang.ClassCastException e){
                   // we cannot intantiate the class - throw the original Axis fault
                    throw f;
                } catch (java.lang.ClassNotFoundException e) {
                    // we cannot intantiate the class - throw the original Axis fault
                    throw f;
                }catch (java.lang.NoSuchMethodException e) {
                    // we cannot intantiate the class - throw the original Axis fault
                    throw f;
                } catch (java.lang.reflect.InvocationTargetException e) {
                    // we cannot intantiate the class - throw the original Axis fault
                    throw f;
                }  catch (java.lang.IllegalAccessException e) {
                    // we cannot intantiate the class - throw the original Axis fault
                    throw f;
                }   catch (java.lang.InstantiationException e) {
                    // we cannot intantiate the class - throw the original Axis fault
                    throw f;
                }
            }else{
                throw f;
            }
        }else{
            throw f;
        }
        } finally {
            _messageContext.getTransportOut().getSender().cleanup(_messageContext);
        }
    }

【问题讨论】:

  • 这是使用 Axis 时的常见异常。这通常意味着客户端和服务器 WSDL/XSD 不同步。
  • 感谢 Reimeus 的回复。令人费解的是,当部署到本地和其他环境时,相同的客户端(ear 项目)和服务器(aar)工作正常。如何在服务器端同步 WSDL/XSD?它是在 aar 中完成的,还是在应用服务器上部署的 axis2 中的某个地方完成的?
  • 这可能是java版本的原因。如果 web 服务部署在 java5 中,而客户端在 java6 中,则可能会出现此错误。也请检查这方面

标签: java web-services soap axis2


【解决方案1】:

这个错误可能有点误导。在我修改了 WSDL 并添加了一个新的强制元素之后,我创建了我的客户端。比这个错误出现了。解决方案是,我忘记在我的 Web 服务的一种方法中填充这个元素。如果出现此错误,还要检查您的必填元素是否已在服务器中填写。 它在一种环境下工作而不在另一种环境下工作也可能意味着在一台服务器(开发服务器)上填写必填项,而不是在另一台服务器(生产服务器)下填写。

【讨论】:

    猜你喜欢
    • 2012-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-06
    相关资源
    最近更新 更多