Cannot call 'x' because it is a web method.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Ive been banging my head on this one since early this morning, and not having much luck with this error on Google.
I am trying to consume a web service written (in .NET 2.0) by someone else, which is located on our company intranet. Currently there is only one other application which utilizes this web service, and it does so with no problems.
However, Ive been unable to find a way to reach this web service through my C# project. Ive simplified it as much as possible, and it still generates the message that "Cannot call object.method because it is a web method."
The entirety of my source code is as follows:

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; using System;
<span style="color:Blue; using System.Collections.Generic;
<span style="color:Blue; using System.Linq;
<span style="color:Blue; using System.Text;
<span style="color:Blue; using System.Net;

<span style="color:Blue; namespace ConsoleApplication1
{
<span style="color:Blue; class Program
{
<span style="color:Blue; static <span style="color:Blue; void Main(<span style="color:Blue; string[] args)
{
teamlink.Service svc = <span style="color:Blue; new teamlink.Service();

svc.Credentials = CredentialCache.DefaultCredentials;
Console.WriteLine(svc.Location(<span style="color:#A31515; "MR-ISWL007"));

Console.ReadLine();
}
}
}

[/code]

My credentials should be sufficient to access the service (the original application also uses the current users credentials), and anonymous authentication is enabled on the server anyway.
Just to make sure I wasnt crazy, I tried consuming an example web service on w3schools.com, with full success: http://www.w3schools.com/webservices/tempconvert.asmx
I dont have access to the original source of the working application, but have looked at the disassembly in Reflector, and its not doing anything more than what my app does. Ive tried running my code under .NET 2.0 and 4.0.
Any ideas?
Thanks,
Ben


View the full article
 
Back
Top