Sure, it's the result.jsp from the orignal geronimo 2.1 WS sample mentioned below, modified to return an array of arbitrary strings. The original sample used a QName to get the service instance (see commented out lines), Jarek suggested in an earlier response to look up the service in jndi instead, neither seems works properly.
<%@ page import="javax.naming.InitialContext,javax.xml.ws.Service,java.net.URL,javax.xml.namespace.QName,javax.xml.ws.Service,org.apache.geronimo.samples.jws.Calculator"%> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Calculator Result</title> </head> <% int value1 = 0; int value2 = 0; String[] sum = null; try { System.out.println( request.getParameter( "value1" ) + " " + request.getParameter( "value2" ) ); value1 = Integer.parseInt( request.getParameter( "value1" ) ); value2 = Integer.parseInt( request.getParameter( "value2" ) ); InitialContext ctx = new InitialContext(); System.err.println("IC:" + ctx); Service service = (Service)ctx.lookup("java:comp/env/services/Calculator"); System.err.println("Service:" + service); //URL url = new URL("http://localhost:8080/jaxws-calculator-1.0/calculator?wsdl"); //QName qname = new //QName("http://jws.samples.geronimo.apache.org", "Calculator"); //Service service = Service.create(url, qname); Calculator calc = (Calculator)service.getPort(Calculator.class); sum = calc.add(value1, value2); } catch ( Exception e ) { e.printStackTrace(); } %> <body> The string array returned has <%=sum.length%> element(s): <% int i; for (i=0; i<sum.length-1; i++) {%> <br><%=sum[i]%><br> <%}%> <br> <a href="index.jsp">Back</a> </body> </html> Fred ---- Kevan Miller <[EMAIL PROTECTED]> wrote: > Strange. Can you share your jsp with us? Are you running with Tomcat/ > Axis2 or Jetty/CXF? > > --kevan > > On Mar 29, 2008, at 12:32 PM, <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote: > > > BTW, the original post wasn't so much about the sample, as it was > > about the proper way to return a String[] from a webservice. I was > > simply using the calculator sample as an easy example of what wasn't > > working. > > > > Fred > > ---- [EMAIL PROTECTED] wrote: > >> No difference, except it pointed out a bug in the geronimo-web.xml > >> of the sample: > >> <uri>/jaxws-calculator/calculator</uri> > >> should be > >> <uri>/jaxws-calculator-1.0/calculator</uri> > >> But once corrected, the result is the same: > >> The string array returned has 7 element(s): > >> Value > >> 1 > >> 34532 > >> Value > >> 2 > >> 54534 > >> > >> Other suggestions? I've tried a lot of different things so far, > >> none have fixed the problem. > >> > >> Fred > >> > >> > >> ---- Jarek Gawor <[EMAIL PROTECTED]> wrote: > >>> Just from a quick glance it looks like the result.jsp is not quite > >>> right. It should look like the one shown here: > >>> http://cwiki.apache.org/GMOxDOC21/simple-web-service-with-jax- > >>> ws.html > >>> (titled add.jsp where jndi lookup is done). See if changing that > >>> helps. > >>> > >>> Jarek > >>> > >>> On Fri, Mar 28, 2008 at 6:00 PM, <[EMAIL PROTECTED]> wrote: > >>>> I'm having a problem returning a String array from a method of a > >>>> webservice. In order to provide a simple way to recreate the > >>>> problem, I modified the 2.1 webservices sample ( > >>>> http://cwiki.apache.org/GMOxDOC21/developing-a-simple-calculator-web-service.html > >>>> > >>>> ) such that the add() method returns a String[] instead of an > >>>> int. The mods were simple, I changed the "return" element of the > >>>> addResponse in the wsdl of the sample > >>>> from: > >>>> <xsd:element name="return" type="xsd:int"/> > >>>> to: > >>>> <xsd:element name="return" type="xsd:string" minOccurs="0" > >>>> maxOccurs="unbounded"/> > >>>> and the CalculatorService.java (and the corresponding interface > >>>> it implements) from: > >>>> public int add(int value1, int value2) { > >>>> ... > >>>> return value1 + value2; > >>>> to: > >>>> public String[] add(int value1, int value2) { > >>>> ... > >>>> return new String[]{"Value 1", String.valueOf(value1), > >>>> "Value 2", String.valueOf(value2), String.valueOf(value1 + > >>>> value2)}; > >>>> > >>>> and then changed the result.jsp to expect a String[] and iterate > >>>> over the contents printing out each element, If I add 3 + 4, I > >>>> expected the result.jsp to display: > >>>> > >>>> Value 1 > >>>> 3 > >>>> Value 2 > >>>> 4 > >>>> 7 > >>>> > >>>> but I get instead: > >>>> Value > >>>> 1 > >>>> 3 > >>>> Value > >>>> 2 > >>>> 4 > >>>> 7 > >>>> > >>>> It seems that in the process of converting the response into a > >>>> Java String[], the whitespace of the individual strings is acting > >>>> as a delimiter. Thus instead of getting an array of 5 strings, I > >>>> get an array of 7 strings instead. What have I misconfigured? > >>>> > >>>> Fred > >>>> > > >
