David's profileWebbert SolutionsBlogLists Tools Help

Blog


    March 08

    Java Client using XFire - Part 1

    Here is the source code for the Java client using XFire.



    /**

     *

     */

    import java.util.List;

    import emp.service.*;

    import emp.data.*;

     

    /**

     * @author delliott

     *

     */

    public class SimpleAsmxXFireClient

    {

     

        /**

         * @param args

         */

        public static void main(String[] args)

        {

            GetPerson();

            GetAddress();

            GetWorkAddress();

        }

       

        /**

         *

         */

        public static void GetPerson()

        {

            Person person;

            Person newPerson;

     

            try

            {

                // Create Proxy Class

                SimpleAsmxServiceClient service = new SimpleAsmxServiceClient();

               

                // Create Person

                person = new Person();

                person.setName( "Bob the Builder" );

     

                //

                // DO NOT SEND THE ADDRESS

                //

                System.out.println( "\nDo NOT send Address to Service..." );

                newPerson = service.getSimpleAsmxServiceSoap().getPerson( person );

                Print( newPerson );

               

                //

                // SEND THE ADDRESS

                //

                System.out.println( "\nSend Address to Service..." );

                HomeAddress homeAddress = new HomeAddress();

                homeAddress.setHouseNumber("456 Long and Winding Road ");

                person.setAddress(homeAddress);

               

                newPerson = service.getSimpleAsmxServiceSoap().getPerson( person );

                Print( newPerson );

            }

            catch ( Exception ex )

            {

                System.err.println(ex);

            }

        }

     

        /**

         * @param newPerson

         */

        public static void Print( Person newPerson )

        {

            Object o;

           

            if ( newPerson != null )

            {

                System.out.println( "    Name: " + newPerson.getName() );

               

                o = newPerson.getAddress();

                if ( o != null)

                {

                    System.out.println( "    Addr: " + ( (HomeAddress)newPerson.getAddress() ).getHouseNumber() );

                }

                else

                {

                    System.out.println( "    Addr: is null"  );

                }

            }

        }

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.
    David Elliott has turned off comments on this page.

    Trackbacks

    The trackback URL for this entry is:
    http://webbertsolutions.spaces.live.com/blog/cns!E02420377ABA0395!122.trak
    Weblogs that reference this entry
    • None