views:

1688

answers:

1

The Code Snippet is as follwos

namespace RecruiterWebService
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>


    [WebService(Namespace = "http://tempuri.org/") ]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    public class **Service1** : System.Web.Services.WebService
    {


        [WebMethod]
        public XmlDocument Insert(XmlDocument Jobs)
        { }

        [WebMethod]
        public XmlDocument Update(XmlDocument Jobs)
        { }

        [WebMethod]
        public XmlDocument Delete(XmlDocument Jobs)
        { }

        [WebMethod]
        public XmlDocument Insert(string JobPath)
        { }

        [WebMethod]
        public XmlDocument Update(string JobPath)
        { }

        [WebMethod]
        public XmlDocument Delete(string JobPath)
        { }

        [WebMethod]
        public XmlDocument FeedBack(string UserName, string Password)
        { }


    }
}

My Questions are:-

  1. How can I change the name of the WebService from Service1 to lets say Jobs..I tried doing this but then while adding the WebReference its was giving Exception.

  2. Here in this webservice I am using Method Overloading but aginb while Adding WebReference its throwing the Exception and suggets using Message Attribute which I am not able to understand.

  3. After Resolving the above two bugs as per your Suggestion..I am having problem with the return type. I am using XMLDocument as the return type of all the WEBMethods but after adding it as web reference to the Client the Return Type of The Methods get changed to XMLNode how can I resolve this

Waiting for Response guys..

+2  A: 

1: If you change the class name, you must also change the .asmx (or .svc for WCF) page, which has a (text) marker to Service1. Right-click the asmx and "View markup" - it should look something like:

<%@ WebService Language="C#" CodeBehind="Service1.asmx.cs" Class="WebService1.Service1" %>

Change the Class and CodeBehind to match your current setup.

2: ws 1-1 doesn't support overloading. You simply need to add an attribute to give a unique name to each method on the SOAP interface. However, note that this becomes the method name that your proxies will see.

For example, you might change one of the messages as below:

    [WebMethod(MessageName = "InsertXml")]
    public XmlDocument Insert(XmlDocument Jobs)
    { ... }

Now update the client; you (if you use wsdl.exe etc) will probably have an InsertXml(...) method.

Marc Gravell