2010-01-20 61 views
1

當這樣的錯誤會發生?Web服務:BeanSerializer

<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) 

回答

2

每當元件standardHeader設置爲null,但它被標記爲在XSD nillable="false"

+0

請詳細說明 – vetri02 2010-01-20 16:00:15

+1

給你的代碼的一些有意義的部分,我會的。 – Bozho 2010-01-20 16:22:01

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"/> 
0

設置的minOccurs = 0元場XSD,

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);