2 Replies Latest reply on Dec 5, 2005 2:11 PM by luigi.tascapani

    Return a String[] from a WebService using NetBeans Ide

    luigi.tascapani

      Hi all, if I try to invoke a web service that return a String[] i have this error when i try to test it with netBeans:

      Runtime exception; nested exception is: deserialization error: unexpected XML reader state. expected: END but found: START: item

      When deployng WS.. JBoss console print out:

      JavaWsdlMapping] Cannot find jaxrpc-mapping for type: {urn:NewWebService/types/arrays/java/lang}StringArray

      I know it is a known problem but i haven't understand if someone solved it, and how.

        • 1. Re: Return a String[] from a WebService using NetBeans Ide
          thomas.diesler

          The way to think about this goes like this:

          1) Take a service endpoint interface (SEI)

          public interface MyEndpoint
          {
           String[] echoStringArray(String[] v)
          }
          


          2) Run a tool that generates wsdl + schema + mapping

           <complexType name="StringArray">
           <sequence>
           <element name="value" type="string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
           </sequence>
           </complexType>
          
           <message name=echoStringArray">
           <part name="arrayOfString_1" type="ns3:StringArray"/>
           </message>
           <message name="MarshallRpcServiceInterface_echoStringArrayResponse">
           <part name="result" type="ns3:StringArray"/>
           </message>
          


          3) Look for the java mapping for that array type

           <java-xml-type-mapping>
          <java-type>somepackage.StringArray</java-type>
           <root-type-qname xmlns:typeNS="{urn:NewWebService/types/arrays/java/lang}StringArray ">typeNS:StringArray</root-type-qname>
           <qname-scope>complexType</qname-scope>
           <variable-mapping>
           <java-variable-name>stringArr</java-variable-name>
           <xml-element-name>stringArr</xml-element-name>
           </variable-mapping>
           </java-xml-type-mapping>
          


          4) Make sure the wrapper type is in your deployment

          If you run wscompile with -keep, it keeps the generated java types

          You could also have a look at

          tdiesler@satellite /cygdrive/d/projects/jboss-branch/jboss-4.0.x/testsuite
          $ ant -Dtest=webservice/marshalltest test
          
          test:
           [junit] Running org.jboss.test.webservice.marshalltest.MarshallDocLiteralTestCase
           [junit] Tests run: 31, Failures: 0, Errors: 0, Time elapsed: 46.777 sec
           [junit] Running org.jboss.test.webservice.marshalltest.MarshallRpcEncodedTestCase
           [junit] Tests run: 31, Failures: 0, Errors: 0, Time elapsed: 22.352 sec
           [junit] Running org.jboss.test.webservice.marshalltest.MarshallRpcLiteralTestCase
           [junit] Tests run: 31, Failures: 0, Errors: 0, Time elapsed: 21.481 sec
          


          These tests marshall String[] as well


          • 2. Re: Return a String[] from a WebService using NetBeans Ide
            luigi.tascapani

            Thank's, i'll try the -kepp option, it's interesting.. to solve rapidely my problem I've made a MyStringArray class that contains a field value of type String[] and a get/set method. MyStringArray extends Serializable, and it works.

            The problem is that WebService and all xml files to configure are so complexxx and I haven't so much time in these days.. But finaly i did it,
            thanx
            good bye