none
.Net 4.5 Normal web service (No WCF) - how to pass parameters? RRS feed

  • Question

  • Hello everyone,

    I have created a normal web service in .Net 4.5. I would like to access this webserive in Excel 2013 with a new webservice() method. I have hosted this web service on internal network. There is one parameter of string type of my webmethod. I would like to pass the value of this parameter in web service URL.

    How can I pass the parameters of web method in URL?

    Below is my web method:

    <System.Web.Services.WebMethod()> Public Function CheckIfURLIsValid(ByVal Core As String) As String
    
    
                    Dim xDocument As System.Xml.Linq.XDocument = New System.Xml.Linq.XDocument(New System.Xml.Linq.XElement("Root", "True"))
    
                    Return xDocument.ToString
    
                    
    
            End Function

    I would like to pass the value of Core variable when I access the web service in internet explorer.


    Thanks, Ankit Shah


    Inkey Solutions, India.
    Microsoft Certified Business Management Solutions Professionals
    http://www.inkeysolutions.com/MicrosoftDynamicsCRM.html



    Thursday, December 12, 2013 10:36 AM

Answers

  • By default ASMX works with POST method and designed for Soap request. You have two options,

    Generate a SOAP request either through add web reference or use SOAP SDK from Exceel and consume it

    Or

    You need to decorate your web method with

    [ScriptMethod(UseHttpGet = true)]

    i.e

    [WebMethod]
    [ScriptMethod(UseHttpGet = true)]
    public string EchoStringAndDate(DateTime dt, string s)
    {
        return s + ":" + dt.ToString();
    }
    
    

    And following configuration @ web.config

    system.web>
    <webServices>
      <protocols>
        <add name="HttpGet"/>
      </protocols>

    http://XXX.com/abc.asmx/CheckIfURLIsValid?core=12345


    Lingaraj Mishra

    Thursday, December 12, 2013 2:07 PM

All replies

  • By default ASMX works with POST method and designed for Soap request. You have two options,

    Generate a SOAP request either through add web reference or use SOAP SDK from Exceel and consume it

    Or

    You need to decorate your web method with

    [ScriptMethod(UseHttpGet = true)]

    i.e

    [WebMethod]
    [ScriptMethod(UseHttpGet = true)]
    public string EchoStringAndDate(DateTime dt, string s)
    {
        return s + ":" + dt.ToString();
    }
    
    

    And following configuration @ web.config

    system.web>
    <webServices>
      <protocols>
        <add name="HttpGet"/>
      </protocols>

    http://XXX.com/abc.asmx/CheckIfURLIsValid?core=12345


    Lingaraj Mishra

    Thursday, December 12, 2013 2:07 PM
  • Thanks Lingaraj. Your last option works for me. Thank you again.

    Thanks, Ankit Shah


    Inkey Solutions, India.
    Microsoft Certified Business Management Solutions Professionals
    http://www.inkeysolutions.com/MicrosoftDynamicsCRM.html

    Friday, December 13, 2013 10:02 AM