You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Rui Oliveira <ra...@gmail.com> on 2012/01/03 18:58:12 UTC

[Axis2] Array String parameter on SOAP Web Service

Since i'm really needing a reply to my research project and no one at the
Axis2 User List managed to reply, i ask here help for the specific problem
i explain below, about developing java web services with Soap array as
parameters.

For the record, i'm using Apache Axis2 1.6.1 build


---------- Forwarded message ----------
From: Rui Oliveira <ra...@gmail.com>
Date: Thu, Dec 29, 2011 at 4:05 PM
Subject: Array String parameter on SOAP Web Service
To: java-user@axis.apache.org


Hi

I'm new to Axis2, and i've developed a soap web service using Eclipse
Helios integration with Axis2 and tomcat. I've tried searching the mailing
list but no solution seemed to address my problem. This is why i send this
email since i don't know what to do anymore! :(

I'm trying to pass a string of array to the following web service function:

package pt.uc.dei.MyWebService;

public class MyWebService {
//other functions ignored
(...)

    public int getArray(String[]result) {
       return (result.length);
   }
}

The WSDL generated is attached with this email (it has definitions of other
operations but getArray is the one with the problem)


However when i use SOAPUI to generate a client. The default request that
SoapUI generate is:

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"<http://schemas.xmlsoap.org/soap/envelope/>xmlns:myw=
"http://MyWebService.dei.uc.pt" <http://mywebservice.dei.uc.pt/>>
    <soapenv:Header/>
         <soapenv:Body>
           <myw:getArray>
                <myw:result>?</myw:result>
           </myw:getArray>
         </soapenv:Body>
</soapenv:Envelope>


I've edited the soap envelop tag, and the request content inside result tag
it in order to support an array like this:

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"<http://schemas.xmlsoap.org/soap/envelope/>
xmlns:xsd="http://www.w3.org/2001/XMLSchema"<http://www.w3.org/2001/XMLSchema>xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"<http://www.w3.org/2001/XMLSchema-instance>xmlns:SOAP-ENC=
"http://schemas.xmlsoap.org/soap/encoding/"<http://schemas.xmlsoap.org/soap/encoding/>xmlns:myw=
"http://MyWebService.dei.uc.pt" <http://mywebservice.dei.uc.pt/>>
<soapenv:Header/>
  <soapenv:Body>
    <myw:getArray>
         <myw:result>
            <param SOAP-ENC:arrayType="xsd:string[4]" >
                 <item xsi:type="xsd:string">Egypt</item>
                 <item xsi:type="xsd:string">Amsterdam</item>
                 <item xsi:type="xsd:string">Lisbon</item>
                 <item xsi:type="xsd:string">Paris</item>
            </param>
         </myw:result>
    </myw:getArray>
  </soapenv:Body>
</soapenv:Envelope>

However the response i get from the getArray operation is :

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"<http://schemas.xmlsoap.org/soap/envelope/>>

   <soapenv:Body>
      <ns:getArrayResponse
xmlns:ns="http://MyWebService.dei.uc.pt"<http://mywebservice.dei.uc.pt/>>

          <ns:return>1</ns:return>
      </ns:getArrayResponse>
   </soapenv:Body>
</soapenv:Envelope>


It seems like the array of strings is being converted to one dimensional
empty Array, and i'm not receiving the strings inside the soap array from
the request.

Can anyone provide me what is causing this and if my request is being built
correctly?

Best Regards