Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

Axis webservice returning an array of class

Thread view: 
jeremy - 10 Mar 2007 01:04 GMT
I've created a class with two public properties of type string
(example below).  I've created a method in my web service which
returns an array of the class.  Compiles fine, but the class
properties don't appear in the web service response, or in the wsdl.
Any help appreciated.

Example:

Class I want to return an array of:
public class WorkGroup implements java.io.Serializable
{
   static final long serialVersionUID = 1;
   public String Name;
   public String SearchCode;

   public WorkGroup(IWorkGroup pWorkGroup)
   {
       this.Name = pWorkGroup.getName();
       this.SearchCode = pWorkGroup.getSearchcode();
}

WebService:

public Class PersonWS
{
   public WorkGroup[] ListWorkGroups(String strPerson)
   {
      ....
   }
}

WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://localhost:8080/axis/
PersonWS.jws" xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://localhost:8080/axis/PersonWS.jws"
xmlns:intf="http://localhost:8080/axis/PersonWS.jws"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns1="http://openview.interiorhealth.ca" xmlns:wsdl="http://
schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/
wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
 <schema targetNamespace="http://localhost:8080/axis/PersonWS.jws"
xmlns="http://www.w3.org/2001/XMLSchema">
  <import namespace="http://openview.interiorhealth.ca"/>
  <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
  <complexType name="ArrayOf_tns1_WorkGroup">
   <complexContent>
    <restriction base="soapenc:Array">
     <attribute ref="soapenc:arrayType"
wsdl:arrayType="tns1:WorkGroup[]"/>
    </restriction>
   </complexContent>
  </complexType>
 </schema>
</wsdl:types>

  <wsdl:message name="ListWorkGroupsRequest">

     <wsdl:part name="strPerson" type="xsd:string"/>

  </wsdl:message>

  <wsdl:message name="ListWorkGroupsResponse">

     <wsdl:part name="ListWorkGroupsReturn"
type="impl:ArrayOf_tns1_WorkGroup"/>

  </wsdl:message>

  <wsdl:portType name="PersonWS">

     <wsdl:operation name="ListWorkGroups"
parameterOrder="strPerson">

        <wsdl:input message="impl:ListWorkGroupsRequest"
name="ListWorkGroupsRequest"/>

        <wsdl:output message="impl:ListWorkGroupsResponse"
name="ListWorkGroupsResponse"/>

     </wsdl:operation>

  </wsdl:portType>

  <wsdl:binding name="PersonWSSoapBinding" type="impl:PersonWS">

     <wsdlsoap:binding style="rpc" transport="http://
schemas.xmlsoap.org/soap/http"/>

     <wsdl:operation name="ListWorkGroups">

        <wsdlsoap:operation soapAction=""/>

        <wsdl:input name="ListWorkGroupsRequest">

           <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/
soap/encoding/" namespace="http://DefaultNamespace" use="encoded"/>

        </wsdl:input>

        <wsdl:output name="ListWorkGroupsResponse">

           <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/
soap/encoding/" namespace="http://localhost:8080/axis/PersonWS.jws"
use="encoded"/>

        </wsdl:output>

     </wsdl:operation>

  </wsdl:binding>

  <wsdl:service name="PersonWSService">

     <wsdl:port binding="impl:PersonWSSoapBinding" name="PersonWS">

        <wsdlsoap:address location="http://localhost:8080/axis/
PersonWS.jws"/>

     </wsdl:port>

  </wsdl:service>

</wsdl:definitions>
Alan Cui - 10 Mar 2007 02:46 GMT
I am not sure if Axis would expose these two FIELDs within Web
Service. But why don't you declare them as properties with getter and
setter method? I believe it could work.

> I've created a class with two public properties of type string
> (example below).  I've created a method in my web service which
[quoted text clipped - 125 lines]
>
> </wsdl:definitions>
jeremy - 12 Mar 2007 17:13 GMT
I didn't know you could do properties in java.  how?

> I am not sure if Axis would expose these two FIELDs within Web
> Service. But why don't you declare them as properties with getter and
[quoted text clipped - 131 lines]
>
> - Show quoted text -
jeremy - 12 Mar 2007 23:18 GMT
Ok, I changed the class to use the get and set methods, but I'm still
having the same problem

public class WorkGroup implements java.io.Serializable
{
   static final long serialVersionUID = 1;
   private String strName_m;
   private String strSearchCode_m;

   public WorkGroup()
   {
   }
   public WorkGroup(IWorkGroup pWorkGroup)
   {
       this.Name = pWorkGroup.getName();
       this.SearchCode = pWorkGroup.getSearchcode();
   }

   public String getName()
    {
        return strName_m;
    }

    public void setName(String strName)
    {
        strName_m = strName;
    }

    public String getSearchCode()
    {
        return strSearchCode_m;
    }

    public void setSearchCode(String strSearchCode)
    {
        strSearchCode_m = strSearchCode;
    }
}

> I am not sure ifAxiswould expose these two FIELDs withinWebService. But why don't you declare them as properties with getter and
> setter method? I believe it could work.
[quoted text clipped - 130 lines]
>
> - Show quoted text -


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.