Reputation: 12019
semi Resolved
It appears that the problem exists only when running in debug mode, and only when running the commands thru the immediate / watch windows.
It just works this way. Thanks for the answers.
I'm trying to consume a WCF service from .net 2.0 application.
I've added it as a web reference, the class appeared in the intellisense.
But, calling a method from the service returns an error of
Cannot call <method> because it is a web method
Service
[ServiceContract]
[AspNetCompatibilityRequirments(RequirmentsMode = ApsNetCompatibilityRequirments.Allowed)]
public class ConsumerResponder
{
[OperationConract]
public List<string> GetStrings(int a, int b, int c)
{
return new List<string>{"hi"};
}
}
Services web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.ServiceModel>
<behaviors>
<endpointBehaviors>
<behavior name="bh1">
<endpointDiscovery enabled="true" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetada httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="Service.ConsumerResponder">
<endpoint address="" behaviorConfiguration="bh1" binding="basicHttpBinding" contract="Service.ConsumerResponder" />
<endpoint address="mex" binding="wsHtppBinding" contract="IMetadataExchange" />
</service>
</services>
</system.ServiceModel>
</configuration>
Usage
using(ConsumerResponder cf = new ConsumerResponder())
{
List<string> result = cf.GetStrings(1, true, 2, true, 3, true);
}
Tested from another places and in debug, and the service really returns values.
Upvotes: 1
Views: 3721
Reputation: 4519
You spelt "Contract" wrong.
[OperationConract]
public List<string> GetStrings(int a, int b, int c)
should be
[OperationContract]
public List<string> GetStrings(int a, int b, int c)
Upvotes: 0
Reputation: 1218
Can you atleast try to test your service with SOAP UI i.e. tool to test and services hosted on basic http binding. It will definitely give you idea if there is any problem?
Upvotes: 0
Reputation: 1221
[ServiceContract]
[AspNetCompatibilityRequirments(RequirmentsMode = ApsNetCompatibilityRequirments.Allowed)] public interface IConsumerResponder {
[OperationConract]
public List<string> GetStrings(int a, int b, int c);
}
public class ConsumerResponder:IConsumerResponder
{
public List<string> GetStrings(int a, int b, int c) {
return new List<string>; }
}
using(ConsumerResponder cf = new ConsumerResponder()) {
List<string> = cf.GetStrings(1,2,3); }
May be you can try this instead of the class.
Upvotes: 1
Reputation: 671
I think you should use WSE on the .NET 2.0 side.
This link may help you:
Interoperability between WCF and WSE 3.0
Upvotes: 0
Reputation: 1221
.Net 2.0 is the runtime. So I am assuming when you say .Net 2.0 Enterprise Edition, you are talking about the Visual Studio toolset (Visual Studio 2005).
WCF appeared for the first time in .Net 3.- so .Net 2.0 does not have WCF. However,you can install .Net 3.0 on top of your .Net 2.0 install and start using WCF.
Upvotes: 0