How to write Services.xml of web services

I have four operations in a service class
1. createNewAd  ---> Its signature: public static int createNewAd(String content, String endDate)
2. editExistingAd--> Its signature: public static boolean editExistingAd(ClassifiedAd adToEdit)
3. getExistingAds--> Its signature: public static ClassifiedList getExistingAds()
4. finalizeIssue---> Its signature: public static void finalizeIssue(String dateToFinalize)

When I write services.xml for the above operations I am facing the following issues.
I am developing web services on netbeans.I am having some issues with services.xml.  As I am writing services.xml I am getting the following issues
1. Why do we need two mesageReceiverElements for an operation
2. In case for question above, one is for input and other is for output( I am not sure), how many MessageReceive elements do we need to have if a method has two input parameters and one output parameter(return type).
3. If a method doesnot take any parameters as input values and only has return values I am not finding any outonly class.
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/out-only"
                         class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/> --> what should be the class.
It has the following classes
RPCInOutMessageReceiver       
RPCMethod                               RPCMethod
RPCParameter                                 RPCParameter
RPCRequestElement                   RPCResponseElement
RPCResponseElement                   RPCResponseElement
RPCValues                               RPCValues
4.In one word please help me in writing a services.xml for the following Service Class.

5. The ant file below is always generating settings.xml outside META-INF. It is supposed to be generated inside META-INF. Can I have an ant script which generates settings.xml inside META-INF.

I am pasting the services.xml amd the three .java file(Service file, pojo file, and an other supporting file)

///////////////////////////////////////////////////
//////////////services.xml
<service name="HelloService" scope="application" 
targetNamespace="http://org.dailymoon.classifieds.ClassifiedService/">
    <description>
        Classified Service
    </description>
    <!--<messageReceivers>-->
    <Parameter name="ServiceClass">
        org.dailymoon.classifieds.ClassifiedService
    </Parameter>
	<operation name="createNewAd"  mep="http://www.w3.org/2004/08/wsdl/in-out">
        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
                         class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
                         class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
    <!--</messageReceivers>-->
    </operation>
	
    <operation name="editExistingAd"  mep="http://www.w3.org/2004/08/wsdl/in-out">
        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
                         class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
                         class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
    <!--</messageReceivers>-->
    </operation>
	
	<operation name="getExistingAds">
        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/out-only"
                         class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
                         class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
    <!--</messageReceivers>-->
    </operation>
	
	<operation name="finalizeIssue">
        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
                         class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
                         class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
    <!--</messageReceivers>-->
    </operation>
    <schema schemaNamespace="http://ClassifiedService.classifieds.dailymoon.org/xsd"/>
    <parameter name="ServiceClass">org.dailymoon.classifieds.ClassifiedService</parameter>
</service>

/////////////////////////////////////////////////////
//////////////////ant build file
<?xml version="1.0" encoding="UTF-8"?>
<project name="WSDLTest" default="-post-compile" basedir=".">
    <description>Builds, tests, and runs the project Axis2EchoProject.</description>
    <import file="nbproject/build-impl.xml"/>
    <property environment="env"/>
    <property name="AXIS2_HOME" value="D:/prasad/axis2-1.5.1"/>
    <property name="build.dir" value="build"/>

 <path id="axis2.classpath">
        <fileset dir="${AXIS2_HOME}/lib">
            <include name="*.jar"/>
        </fileset>
    </path>

    <target name="java2wsdlBuild">
        <taskdef name="java2wsdl"
                 classname="org.apache.ws.java2wsdl.Java2WSDLTask"
                 classpathref="axis2.classpath"/>
        <java2wsdl className="org.dailymoon.classifieds.ClassifiedService"
                   outputLocation="${build.dir}/${name}.wsdl"
                   targetNamespace="http://axis.echo.service/"
                   schemaTargetNamespace="http://axis.echo.service/xsd">
            <classpath>
                <pathelement path="${axis2.classpath}"/>
                <pathelement location="${build.dir}/classes"/>
            </classpath>
        </java2wsdl>
    </target>

    <target name="-post-compile" depends="java2wsdlBuild">
        <!--aar them up -->
        <copy toDir="${build.dir}/classes" failonerror="false">
            <fileset dir="${basedir}/resources">
                <include name="**/*.xml"/>
            </fileset>
        </copy>
        <jar destfile="${build.dir}/ClassifiedService.aar">
            <fileset excludes="**/Test.class" dir="${build.dir}/classes"/>
        </jar>
    </target>

    <target name="clean">
        <delete dir="${build.dir}"/>
    </target>
</project>

/////////////////////////////////////////////////////
/////////////////////Service java file

package org.dailymoon.classifieds;

/**
 *
 * @author Owner
 */
public class ClassifiedService {
  public static int createNewAd(String content, String endDate){

      ClassifiedAd newAd = new ClassifiedAd();
      newAd.setEndDate(endDate);
      newAd.setContent(content);
      newAd.save();

      return 1;

   }

   public static boolean editExistingAd(ClassifiedAd adToEdit){

      //Do stuff with the ad here
      return true;

   }


   public static ClassifiedList getExistingAds(){

       ClassifiedAd[] listOfAds = {new ClassifiedAd(), new
 ClassifiedAd(), new ClassifiedAd()};
       ClassifiedList listToReturn = new ClassifiedList(listOfAds);
       return listToReturn;
   }

   public static void finalizeIssue(String dateToFinalize){
       //Don't return anything.
       System.out.println(dateToFinalize + " finalized.");
   }

   public static void main (String args[]){

         ClassifiedService.createNewAd(
           "Eclipse experts needed.  Contact Nick for details.",
                                                   "4/21/2006");

         ClassifiedAd adToEdit = new ClassifiedAd();
         adToEdit.setId(1);
         adToEdit.setStartDate("4/8/2006");
         adToEdit.setEndDate("4/30/2006");
         adToEdit.setContent(
             "Geronimo experts needed.  Contact Nick for details.");

         ClassifiedService.editExistingAd(adToEdit);

         ClassifiedList adList = ClassifiedService.getExistingAds();
         System.out.println(adList.toString());

   }

}

///////////////////////////////////////////////////
//////////pojo file

package org.dailymoon.classifieds;

/**
 *
 * @author Owner
 */
public class ClassifiedAd {
private int id;
   private String startDate;
   private String endDate;
   private String content;

   public void setId(int newId){
      id = newId;
   }

   public void setStartDate(String newStart){
      startDate = newStart;
   }

   public void setEndDate(String newEnd){
      endDate = newEnd;
   }

   public void setContent(String newContent){
      content = newContent;
   }

   public void save(){
       //Save data here
       System.out.println("Ad saved.");
   }

}

//////////////////////////////////////////////////
///////////////////supporting java file

package org.dailymoon.classifieds;

/**
 *
 * @author Owner
 */
public class ClassifiedList {
public ClassifiedAd[] listOfAds;

    public ClassifiedList(ClassifiedAd[] newListOfAds){
        listOfAds = newListOfAds;
    }

    public ClassifiedAd[] getRawAds(){
         return listOfAds;
    }

    public String toString(){
         return "This is a string of results.";
    }
}

Open in new window

prsubjectAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

anilallewarCommented:
1. You would notice that the 2 message recievers are for either input/output only or both operations. Hence consider them as maybe one-way and 2-way traffic implementations.
2. Depends on how it is interpreted; but the operation can be one-way in one direction only as the 2nd direction is taken care of in the 2-way traffic.
3. See answer to #2
4. Since it is build directly with the ant task, it is the best way to do it.
5. Change the path of outputLocation in outputLocation target as below if you want your service.xml under build/META-INF

<java2wsdl className="org.dailymoon.classifieds.ClassifiedService"
                   outputLocation="${build.dir}/META-INF/${name}.wsdl"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
prsubjectAuthor Commented:
How many message receivers should I write if a method doesnt accept any parameters.
0
anilallewarCommented:
In that case it should be out and in-out(in case you add input params later).
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.