Web Services called directly not working

Discussion in 'ASP .Net Web Services' started by tshad, Mar 28, 2006.

  1. tshad

    tshad Guest

    I am playing with web Services and soap and in the article I am using I
    created a page:

    ***********************************************************************
    <%@ WebService Language="c#" Class="FirstWebService" %>

    using System;
    using System.Web;
    using System.Web.Services;

    public class FirstWebService {

    [WebMethod]
    public string HelloWorld(string lcName) {
    return "Hello World, " + lcName;
    }

    [WebMethod]
    public decimal AddNumbers(decimal lnNumber1, decimal lnNumber2) {
    return lnNumber1 + lnNumber2;
    }

    /*

    [WebMethod]

    public DateTime GetServerTime() {

    return DateTime.Now;

    } */
    }
    ***********************************************************************

    If I call http://localhost/FirstWebService.asmx, I get the services test
    windows fine.

    But if I do:
    http://localhost/FirstWebService.asmx/AddNumbers?lnNumbers1=10&lnNumber2=20

    I get an error:
    ***********************************************************************************
    Request format is unrecognized.
    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information
    about the error and where it originated in the code.

    Exception Details: System.InvalidOperationException: Request format is
    unrecognized.

    Source Error:

    An unhandled exception was generated during the execution of the current web
    request. Information regarding the origin and location of the exception can
    be identified using the exception stack trace below.

    Stack Trace:


    [InvalidOperationException: Request format is unrecognized.]
    System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type
    type, HttpContext context, HttpRequest request, HttpResponse response) +388
    System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext
    context, String verb, String url, String filePath) +94
    System.Web.HttpApplication.MapHttpHandler(HttpContext context, String
    requestType, String path, String pathTranslated, Boolean useAppConfig) +699
    System.Web.MapHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
    +95
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
    completedSynchronously) +173
    **************************************************************************************************

    What is missing?

    Thanks,

    Tom
     
    tshad, Mar 28, 2006
    #1
    1. Advertising

  2. tshad

    Martin Kulov Guest

    "tshad" <> wrote in message
    news:...
    >I am playing with web Services and soap and in the article I am using I
    >created a page:
    >
    > If I call http://localhost/FirstWebService.asmx, I get the services test
    > windows fine.
    >
    > But if I do:
    > http://localhost/FirstWebService.asmx/AddNumbers?lnNumbers1=10&lnNumber2=20
    >
    > I get an error:
    > ***********************************************************************************
    > Request format is unrecognized.
    > Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information
    > about the error and where it originated in the code.
    >
    > Exception Details: System.InvalidOperationException: Request format is
    > unrecognized.


    > What is missing?
    >
    > Thanks,
    >
    > Tom


    Hi Tom,

    you can issue GET request only from the localhost by default for debugging
    purposes only. Using GET requests in production environment is considered
    insecure due to some XSS problems.
    Still if you need to enable it use the following configuration in
    web.config:

    <webServices>
    <protocols>
    <add name="HttpGet"/>
    </protocols>
    </webServices>

    HTH,

    --
    Martin Kulov
    http://www.codeattest.com/blogs/martin

    MCT
    MCSD.NET Early Achiever
     
    Martin Kulov, Mar 28, 2006
    #2
    1. Advertising

  3. tshad

    tshad Guest

    That was what I was looking for.

    Thanks,

    Tom.

    "Martin Kulov" <> wrote in message
    news:...
    > "tshad" <> wrote in message
    > news:...
    >>I am playing with web Services and soap and in the article I am using I
    >>created a page:
    >>
    >> If I call http://localhost/FirstWebService.asmx, I get the services test
    >> windows fine.
    >>
    >> But if I do:
    >> http://localhost/FirstWebService.asmx/AddNumbers?lnNumbers1=10&lnNumber2=20
    >>
    >> I get an error:
    >> ***********************************************************************************
    >> Request format is unrecognized.
    >> Description: An unhandled exception occurred during the execution of the
    >> current web request. Please review the stack trace for more information
    >> about the error and where it originated in the code.
    >>
    >> Exception Details: System.InvalidOperationException: Request format is
    >> unrecognized.

    >
    >> What is missing?
    >>
    >> Thanks,
    >>
    >> Tom

    >
    > Hi Tom,
    >
    > you can issue GET request only from the localhost by default for debugging
    > purposes only. Using GET requests in production environment is considered
    > insecure due to some XSS problems.
    > Still if you need to enable it use the following configuration in
    > web.config:
    >
    > <webServices>
    > <protocols>
    > <add name="HttpGet"/>
    > </protocols>
    > </webServices>
    >
    > HTH,
    >
    > --
    > Martin Kulov
    > http://www.codeattest.com/blogs/martin
    >
    > MCT
    > MCSD.NET Early Achiever
    >
    >
     
    tshad, Mar 28, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Saumendra
    Replies:
    0
    Views:
    1,262
    Saumendra
    Jun 24, 2003
  2. Ed Hauptman
    Replies:
    7
    Views:
    1,070
    Ed Hauptman
    Aug 7, 2009
  3. David Cornelson

    Asynchronous Web Services called from ASP.NET

    David Cornelson, Dec 8, 2003, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    152
    Ágúst
    Dec 9, 2003
  4. John
    Replies:
    4
    Views:
    488
  5. haode
    Replies:
    1
    Views:
    121
    Alexander Popkov
    Jun 12, 2004
Loading...

Share This Page