David's profileWebbert SolutionsBlogLists Tools Help

Blog


    March 08

    Web Service - Part 1

    Here is the source code for the .NET Web Service as described in the previous blog.

    Save the following code into a file named SimpleAsmxService.asmx and place it in C:\Inetpub\wwwroot for IIS to use.



    <%@WebService Language="C#" Class="MyService.Simple.SimpleAsmxService" %>

     

    using System.Web.Services;

    using System.Collections.Generic;

    using System.Xml.Serialization;

           

    namespace MyService.Simple

    {

        [WebService( Namespace = "urn:emp:service" )]

        public class SimpleAsmxService : WebService

        {

            [WebMethod]

            public Person GetPerson( Person person )

            {

                Person newPerson = new Person();

           

                CreatePerson( person, newPerson );

           

                return ( newPerson );

            }

           

            [WebMethod]

            public List<Address> GetAddressList()

            {

                List<Address> addressList = new List<Address>();

           

                HomeAddress home = new HomeAddress();

                home.HouseNumber = "211 Pine Street";

           

                addressList.Add( home );

           

                return ( addressList );

            }

           

            [WebMethod]

            public List<HomeAddress> GetHomeAddress()

            {

                List<HomeAddress> addressList = new List<HomeAddress>();

           

                WorkAddress work = new WorkAddress();

                work.HouseNumber = "234 State Avenue";

                work.PhoneNumber = "555-1212";

           

                addressList.Add( work );

           

                return ( addressList );

            }

           

            //[WebMethod]

            //public List<WorkAddress> GetMatchingTypes()

            //{

            //    List<WorkAddress> addressList = new List<WorkAddress>();

           

            //    WorkAddress work = new WorkAddress();

            //    work.HouseNumber = "234 State Avenue";

            //    work.PhoneNumber = "555-1212";

           

            //    addressList.Add( work );

           

            //    return ( addressList );

            //}

     

    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!126.trak
    Weblogs that reference this entry
    • None