1

什么时候会出现这样的错误?

 <ERROR> <BeanSerializer> <serialize>  <Exception:>
java.io.IOException: Non nillable element 'standardHeader' is null.
        at org.apache.axis.encoding.ser.BeanSerializer.serialize(BeanSerializer.java:215)
        at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1426)
        at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:914)
        at org.apache.axis.message.RPCParam.serialize(RPCParam.java:200)
        at org.apache.axis.message.RPCElement.outputImpl(RPCElement.java:433)
        at org.apache.axis.message.MessageElement.output(MessageElement.java:1208)
        at org.apache.axis.message.SOAPBody.outputImpl(SOAPBody.java:139)
        at org.apache.axis.message.SOAPEnvelope.outputImpl(SOAPEnvelope.java:477)
        at org.apache.axis.message.MessageElement.output(MessageElement.java:1208)
        at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:315)
        at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:269)
        at org.apache.axis.SOAPPart.saveChanges(SOAPPart.java:530)
        at org.apache.axis.attachments.AttachmentsImpl.getAttachmentCount(AttachmentsImpl.java:519)
        at org.apache.axis.Message.getContentType(Message.java:475)
        at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:775)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
        at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3231)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2002)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1908)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1362)
        at weblogic.work.ExecuteRequestAdapter.execute(ExecuteRequestAdapter.java:21)
        at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:145)
        at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:117)
4

3 回答 3

2

每当元素standardHeader设置为null,但它nillable="false"在 XSD 中被标记为。

于 2010-01-20T15:52:16.183 回答
0

创建 JAXWS 客户端时出现相同的错误:

2016-03-16 10:42:02 ERROR BeanSerializer:274 - Exception:
java.io.IOException: Non nillable element 'createDate' is null.
        at org.apache.axis.encoding.ser.BeanSerializer.serialize(BeanSerializer.java:215)

于是我调查了生成的 JAXWS 类的内容,发现:

elemField = new org.apache.axis.description.ElementDesc();
        elemField.setFieldName("createDate");
        elemField.setXmlName(new javax.xml.namespace.QName("", "createDate"));
        elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
        elemField.setNillable(false);
        typeDesc.addFieldDesc(elemField);

代码的原因

elemField.setNillable(false);

在从 WSDL 创建 JAXWS 客户端时提供 XSD。

<xs:complexType name="AddEventRequestType">
    <xs:sequence>
      <xs:element name="id" type="xs:int"/>
      <xs:element name="createDate" type="xs:string"/>
于 2016-03-16T08:00:36.020 回答
0

在 XSD 中设置 minOccurs=0 元素字段,

    elemField = new org.apache.axis.description.ElementDesc();
    elemField.setFieldName("createDate");
    elemField.setXmlName(new javax.xml.namespace.QName("", "createDate"));
    elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));   
    elemField.setMinOccurs(0); //it's treated as null value 
    elemField.setNillable(false);
    typeDesc.addFieldDesc(elemField);
于 2017-12-13T09:13:00.083 回答