问题
I have the following Tags in a WSDL :
<xs:element name="promoCodeValues" maxOccurs="1" minOccurs="0" >
<xs:complexType>
<xs:sequence>
<xs:element nillable="false" name="promoCode" type="ac:stringMax20"/>
</xs:sequence>
</xs:complexType>
</xs:element>
When I use Eclipse and generate Axis client (using Axis 1.4) I get the following description lines in my class :
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("promoCodeValues");
elemField.setXmlName(new javax.xml.namespace.QName("http://www.moneygram.com/AgentConnect1105", "promoCodeValues"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.moneygram.com/AgentConnect1105", "stringMax20"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
elemField.setItemQName(new javax.xml.namespace.QName("http://www.moneygram.com/AgentConnect1105", "promoCode"));
typeDesc.addFieldDesc(elemField);
In my java code I invoke this to fill the promoCodeValues :
String[] promoCodes = {"test"};
request.setPromoCodeValues(promoCodes);
But in my XML I have a always this :
<promoCodeValues><promoCode xsi:nil="true"/></promoCodeValues>
I have found this on Axis's JIRA : https://issues.apache.org/jira/browse/AXIS-2054?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel#issue-tabs
I followed the provided patch step by step and found that everything was already there (I use axis 1.4). Does anybody knows how to resolve this issue ?? I'm really confused and don't want to migrate to something else.
回答1:
Solved it ! I'm posting the answer just in case someone will have the same problem. Actually there is an option in Eclipse that can be used to generate beans instead of Arrays. Go to Window -> Preferences -> Web services -> Axis Emitter and check
Prefers building beans to straight arrays for wrapped XML array types
Then regenerate you web service client
来源:https://stackoverflow.com/questions/9837869/axis-generating-nil-on-a-non-null-array