2 Replies Latest reply on May 5, 2008 3:50 AM by Richard Opalka

    Urgent!! Web service return object - JBopss 4.2.2.GA

    Peter Pei Guo Newbie

      Hi,

      We are doing some prototyping, JBoss for web service and C# for client. One of the key thing is to return an object from web service. But it did n't seem to work (some kind of limitation???). After some investigation, the problem seems reside on JBoss side, since the WSDL seems missing information.
      Interface:

      package org.jboss.tutorial.webservice.bean;
      
      import javax.jws.WebService;
      import javax.jws.WebMethod;
      import java.rmi.Remote;
      import java.rmi.RemoteException;
      import javax.jws.soap.SOAPBinding;
      import javax.jws.soap.SOAPBinding.Style;
      
      
      @WebService
      @SOAPBinding(style=Style.DOCUMENT)
      public interface Calculator extends Remote
      {
       @WebMethod int add(int x, int y);
      
       @WebMethod int subtract(int x, int y);
       @WebMethod Something dump();
      
      }
      

      Implementation:
      package org.jboss.tutorial.webservice.bean;
      
      import javax.ejb.*;
      import javax.jws.WebService;
      import javax.jws.soap.SOAPBinding;
      import javax.jws.soap.SOAPBinding.Style;
      import javax.naming.*;
      import javax.persistence.*;
      
      import java.sql.*;
      import javax.sql.*;
      
      import javax.annotation.Resource;
      
      @Stateless
      @WebService
      @SOAPBinding(style=Style.DOCUMENT)
      public class CalculatorBean
      {
      
       public int add(int x, int y) {
       return x + y;
       }
      
       public int subtract(int x, int y)
       {
       return x - y;
       }
      
       public Something dump() {
       System.out.println("called");
       return new Something();
       }
      }
      
      

      Definition of Something:
      package org.jboss.tutorial.webservice.bean;
      
      import java.util.*;
      
      public class Something {
       private int a;
       private double b;
       private HashMap<String, ArrayList<String>> c;
      
       public Something() {
       a = 1;
       b = 2.0;
       c = new HashMap<String, ArrayList<String>>();
       {
       ArrayList<String> arr = new ArrayList<String>();
       arr.add("This is fun");
       arr.add("Interesting");
       arr.add("What is this?");
       c.put("first set", arr);
       }
       {
       ArrayList<String> arr = new ArrayList<String>();
       arr.add("Kaveh");
       arr.add("David");
       arr.add("Costa");
       c.put("second set", arr);
       }
       {
       ArrayList<String> arr = new ArrayList<String>();
       arr.add("green apple");
       arr.add("orange orange");
       arr.add("yellow mango");
       c.put("third set", arr);
       }
       {
       ArrayList<String> arr = new ArrayList<String>();
       arr.add("they shoot horse");
       arr.add("sleppless in seattle");
       arr.add("thank you for smoking");
       c.put("bunch of movies", arr);
       }
       }
      }
      
      

      WSDL generated (does not seem to define Something!!!):
      <definitions name='CalculatorBeanService' targetNamespace='http://bean.webservice.tutorial.jboss.org/' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://bean.webservice.tutorial.jboss.org/' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
       <types>
       <xs:schema targetNamespace='http://bean.webservice.tutorial.jboss.org/' version='1.0' xmlns:tns='http://bean.webservice.tutorial.jboss.org/' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
       <xs:element name='add' type='tns:add'/>
       <xs:element name='addResponse' type='tns:addResponse'/>
       <xs:element name='dump' type='tns:dump'/>
       <xs:element name='dumpResponse' type='tns:dumpResponse'/>
       <xs:element name='subtract' type='tns:subtract'/>
       <xs:element name='subtractResponse' type='tns:subtractResponse'/>
      
       <xs:complexType name='add'>
       <xs:sequence>
       <xs:element name='arg0' type='xs:int'/>
       <xs:element name='arg1' type='xs:int'/>
       </xs:sequence>
       </xs:complexType>
       <xs:complexType name='addResponse'>
       <xs:sequence>
       <xs:element name='return' type='xs:int'/>
      
       </xs:sequence>
       </xs:complexType>
       <xs:complexType name='dump'>
       <xs:sequence/>
       </xs:complexType>
       <xs:complexType name='dumpResponse'>
       <xs:sequence>
       <xs:element minOccurs='0' name='return' type='tns:something'/>
       </xs:sequence>
      
       </xs:complexType>
       <xs:complexType name='something'>
       <xs:sequence/>
       </xs:complexType>
       <xs:complexType name='subtract'>
       <xs:sequence>
       <xs:element name='arg0' type='xs:int'/>
       <xs:element name='arg1' type='xs:int'/>
       </xs:sequence>
      
       </xs:complexType>
       <xs:complexType name='subtractResponse'>
       <xs:sequence>
       <xs:element name='return' type='xs:int'/>
       </xs:sequence>
       </xs:complexType>
       </xs:schema>
       </types>
       <message name='CalculatorBean_dumpResponse'>
      
       <part element='tns:dumpResponse' name='dumpResponse'></part>
       </message>
       <message name='CalculatorBean_subtractResponse'>
       <part element='tns:subtractResponse' name='subtractResponse'></part>
       </message>
       <message name='CalculatorBean_subtract'>
       <part element='tns:subtract' name='subtract'></part>
       </message>
       <message name='CalculatorBean_addResponse'>
      
       <part element='tns:addResponse' name='addResponse'></part>
       </message>
       <message name='CalculatorBean_add'>
       <part element='tns:add' name='add'></part>
       </message>
       <message name='CalculatorBean_dump'>
       <part element='tns:dump' name='dump'></part>
       </message>
       <portType name='CalculatorBean'>
      
       <operation name='add' parameterOrder='add'>
       <input message='tns:CalculatorBean_add'></input>
       <output message='tns:CalculatorBean_addResponse'></output>
       </operation>
       <operation name='dump' parameterOrder='dump'>
       <input message='tns:CalculatorBean_dump'></input>
       <output message='tns:CalculatorBean_dumpResponse'></output>
       </operation>
       <operation name='subtract' parameterOrder='subtract'>
      
       <input message='tns:CalculatorBean_subtract'></input>
       <output message='tns:CalculatorBean_subtractResponse'></output>
       </operation>
       </portType>
       <binding name='CalculatorBeanBinding' type='tns:CalculatorBean'>
       <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
       <operation name='add'>
       <soap:operation soapAction=''/>
       <input>
      
       <soap:body use='literal'/>
       </input>
       <output>
       <soap:body use='literal'/>
       </output>
       </operation>
       <operation name='dump'>
       <soap:operation soapAction=''/>
       <input>
      
       <soap:body use='literal'/>
       </input>
       <output>
       <soap:body use='literal'/>
       </output>
       </operation>
       <operation name='subtract'>
       <soap:operation soapAction=''/>
       <input>
      
       <soap:body use='literal'/>
       </input>
       <output>
       <soap:body use='literal'/>
       </output>
       </operation>
       </binding>
       <service name='CalculatorBeanService'>
       <port binding='tns:CalculatorBeanBinding' name='CalculatorBeanPort'>
      
       <soap:address location='http://127.0.0.1:8080/tutorial/CalculatorBean'/>
       </port>
       </service>
      </definitions>