[ https://issues.apache.org/jira/browse/AXIS2-3798?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Detelin Yordanov updated AXIS2-3798: ------------------------------------ Attachment: ArrayOfstring.java > "Unbound namespace URI" Exception while serializing ADBBean > ----------------------------------------------------------- > > Key: AXIS2-3798 > URL: https://issues.apache.org/jira/browse/AXIS2-3798 > Project: Axis 2.0 (Axis2) > Issue Type: Bug > Components: codegen > Affects Versions: 1.4, 1.3 > Environment: Axis2 1.3/1.4, Tomcat 5.5.26 > Reporter: Detelin Yordanov > Attachments: ArrayOfstring.java, full stacktrace.txt, TypeTest.aar, > TypeTestClient.java > > > I have a simple POJO service with the following method: > package org.tempuri.test; > import org.tempuri.test.data.arrays.ArrayOfstring; > > public class TypeTest { > public ArrayOfstring retArrayOfstring(ArrayOfstring inString) { > return inString; > } > } > The ArrayOfstringis declared like this: > package org.tempuri.test.data.arrays; > public class ArrayOfstring { > protected String[] string; > public String[] getString() { > if (string == null) { > string = new String[0]; > } > return this.string; > } > public void setString(String[] string) { > this.string = string; > } > } > I deploy this POJO on an Axis2 1.3/1.4 (both have the issue) runtime running > on Tomcat. > Then I generate a client stub using the following command: > wsdl2java -ap -o ./generated -s -u -uw -uri > http://localhost:8080/axis2-1.4/services/TypeTest?wsdl > I use the stub to invoke the service passing an array of strings that > contains a null element > (this is important since without it I do not get the exception): > ArrayOfstring input = new ArrayOfstring(); > input.setString(new String[]{"Abracadabra", null, "abc"}); > stub.retArrayOfstring(input); > While serializing the ArrayOfstring ADBBean I get an "Unbound namespace URI > 'http://arrays.data.test.tempuri.org/xsd'" exception: > Caused by: javax.xml.stream.XMLStreamException: Unbound namespace URI > 'http://arrays.data.test.tempuri.org/xsd' > at > com.ctc.wstx.sw.SimpleNsStreamWriter.writeStartOrEmpty(SimpleNsStreamWriter.java:239) > at > com.ctc.wstx.sw.BaseNsStreamWriter.writeStartElement(BaseNsStreamWriter.java:312) > at > org.apache.axiom.om.impl.MTOMXMLStreamWriter.writeStartElement(MTOMXMLStreamWriter.java:105) > at > org.apache.axis2.databinding.utils.writer.MTOMAwareXMLSerializer.writeStartElement(MTOMAwareXMLSerializer.java:47) > at > org.tempuri.test.data.arrays.xsd.ArrayOfstring.serialize(ArrayOfstring.java:230) > at > org.tempuri.test.data.arrays.xsd.ArrayOfstring.serialize(ArrayOfstring.java:160) > at > org.tempuri.test.RetArrayOfstring.serialize(RetArrayOfstring.java:203) > at > org.tempuri.test.RetArrayOfstring.serialize(RetArrayOfstring.java:123) > at > org.tempuri.test.RetArrayOfstring$1.serialize(RetArrayOfstring.java:111) > ... > As far as I could investigate this, the problem seems to be that the first > non-null element uses the "prefix2" variable when registering the namespace > leavin "prefix" uninitialized, the null element that follows uses just > "prefix" generating a new value for it and setting it on the current element. > The third non-null string element checks whether "prefix" is not null and > since it is not (because it has been initialized by the null element > handling), > assumes that the prefix and its namespace have already been registered on > this element while they have not been. > This is just an assumption, I might be wrong about it, however I found out > that this is fixed easily by manually adding the following line: > in the serialize(..) method: > ... > for (int i = 0;i < localString.length;i++){ > if (localString[i] != null){ > if (!emptyNamespace) { > prefix = xmlWriter.getPrefix(namespace); //MANUALLY ADDED LINE > if (prefix == null) { > ... -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]