简体   繁体   中英

pass 2 dimensional array as a parameter in a web-service in java

I am trying to make a web-service in java where you pass in a 2 dimensional array as a parameter. When I test it with the web-service explore I keep getting this error:

<soapenv:Fault>
  <faultcode>soapenv:Server.userException</faultcode> 
  <faultstring>org.xml.sax.SAXException: Found character data inside an array element while deserializing</faultstring> 
- <detail>
  <ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">Name</ns1:hostname> 
  </detail>
</soapenv:Fault>

Any idea as to why?

You are best off wrappering your two-dimensional array inside of an object, and even then use something like ArrayList instead of an actual Array. It works better with web services with Java and your JAXB bindings.

public class MyTwoDimensionalArrayWrapper {
  private Collection dimensionOne = new ArrayList();
  private Collection dimensionTwo = new ArrayList();

  ...
  //getters and setters, etc.
  //note I did not put any annotations on this..just a skeleton to give you an idea to help.
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM