Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Having problems with unit testing a web service

Having problems with unit testing a web service

Scheduled Pinned Locked Moved Web Development
testinghelpcsharpwindows-adminbeta-testing
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rafferty Uy
    wrote on last edited by
    #1

    Hi, I can't get my unit test to work. Here is the error I'm getting (I'm using NUnit)

    System.Net.WebException: The request failed with the error message:

    Object moved

    Object moved to here.

    --.

    What could be wrong? Here is an idea of how my current environment: - I created a web application in the localhost IIS (a virtual directory) - under this web app, there is a \WebServices folder containing MyWebService.asmx - In a different solution (also a different directory), I created a Class Library project with a Web Reference to MyWebService.asmx - I tried testing a simple Hello World method (code below) and I'm getting the above error. In MyWebService.asmx

    [WebMethod]
    public string HelloWorld() { return "Hello World!"; }

    In MyWebServiceTest.cs

    [Test]
    public void HelloWorldTest() {
    var svc = new MyWebService();
    var str = svc.HelloWorld();
    Assert.That(str, Is.EqualTo("Hello World!"));
    }

    Thanks in advance for your help.

    Rafferty

    A 1 Reply Last reply
    0
    • R Rafferty Uy

      Hi, I can't get my unit test to work. Here is the error I'm getting (I'm using NUnit)

      System.Net.WebException: The request failed with the error message:

      Object moved

      Object moved to here.

      --.

      What could be wrong? Here is an idea of how my current environment: - I created a web application in the localhost IIS (a virtual directory) - under this web app, there is a \WebServices folder containing MyWebService.asmx - In a different solution (also a different directory), I created a Class Library project with a Web Reference to MyWebService.asmx - I tried testing a simple Hello World method (code below) and I'm getting the above error. In MyWebService.asmx

      [WebMethod]
      public string HelloWorld() { return "Hello World!"; }

      In MyWebServiceTest.cs

      [Test]
      public void HelloWorldTest() {
      var svc = new MyWebService();
      var str = svc.HelloWorld();
      Assert.That(str, Is.EqualTo("Hello World!"));
      }

      Thanks in advance for your help.

      Rafferty

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      When you are testing the application , Your Web services is running ?

      cheers, Abhijit

      R 1 Reply Last reply
      0
      • A Abhijit Jana

        When you are testing the application , Your Web services is running ?

        cheers, Abhijit

        R Offline
        R Offline
        Rafferty Uy
        wrote on last edited by
        #3

        Thanks for replying. Yes my web services are running... I just found out that it's not really a unit test issue but a general web-referencing issue. What I mean is, if I open the web service through my internet browser and invoke the methods, the methods will execute. However, if I create a simple .net project and add a web reference, I get the error stated above. Any idea why? Thanks.

        Rafferty

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups