I seem to be having a problem for getting IErrorHandler interface to work. My code is
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace WcfService3
{
public class Service1 : IService1
{
public string GetData(int value)
{
throw new Exception("asdf");
}
}
public class MyErrorHandler : IErrorHandler
{
public MyErrorHandler()
{
string Hello = "";
}
public bool HandleError(Exception error)
{
return true;
}
public void ProvideFault(Exception error, MessageVersion version, ref Message msg)
{
var vfc = new MyFault();
var fe = new FaultException<MyFault>(vfc);
var fault = fe.CreateMessageFault();
msg = Message.CreateMessage(version, fault, "http://ns");
}
}
public class ErrorHandlerExtension : BehaviorExtensionElement, IServiceBehavior
{
public override Type BehaviorType
{
get { return GetType(); }
}
protected override object CreateBehavior()
{
return this;
}
private IErrorHandler GetInstance()
{
return new MyErrorHandler();
}
void IServiceBehavior.AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
{
}
void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
IErrorHandler errorHandlerInstance = GetInstance();
foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers)
{
dispatcher.ErrorHandlers.Add(errorHandlerInstance);
}
}
void IServiceBehavior.Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
foreach (ServiceEndpoint endpoint in serviceDescription.Endpoints)
{
if (endpoint.Contract.Name.Equals("IMetadataExchange") &&
endpoint.Contract.Namespace.Equals("http://schemas.microsoft.com/2006/04/mex"))
continue;
foreach (OperationDescription description in endpoint.Contract.Operations)
{
if (description.Faults.Count == 0)
{
throw new InvalidOperationException("FaultContractAttribute not found on this method");
}
}
}
}
}
}
My web.config is:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="WcfService3.Service1">
<endpoint address=""
binding="basicHttpBinding"
contract="WcfService3.IService1" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<add name="errorHandler"
type="WcfService3.ErrorHandlerExtension, WcfService3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
My WCF interface is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WcfService3
{
[ServiceContract]
public interface IService1
{
[OperationContract]
[FaultContract(typeof(MyFault))]
string GetData(int value);
}
[DataContract]
public class MyFault
{
}
}
My question is in IErrorHandler in WCF, if there is any exception during the WCF service call, the HandlerError() function is suppose to get called first like the C# windows application UnhandledException class and then the service should crash right? In the code above, during the service call, an exception is thrown but my HandlerError function is not getting called before the exception is thrown? My goal is to log the error and the WCF service can throw the unhandled exception and crash. I was expecting during the debugging that the breakpoint will visit the HandleError function, but that function is not getting called and just an exception shows up?
Aren't you missing <errorHandler /> in your behavior section?
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<!-- HERE -->
<errorHandler />
<!-- HERE -->
</behavior>
The full answer is here. Plus 1 to that answer.
In case anyone else comes across this, when I ran across this error, it was because the error was getting thrown in a method that was called from some LINQ expression. The method wasn't actually called until WCF tried to serialize the response, which then threw outside of the service scope. WCF won't pass these errors to the IErrorHandler.
Materializing the list before returning using .ToList() solved this problem for me.
Related
I'm creating a WCF Service, and it's working fine while I'm connecting it to a WinForms Client. But I want to access it throught the browser. Some methods are working fine, but when I'm trying to send back an object that includes multiples objects it returns the error message "A connection was reset"... I was trying to test my service with ARC and with JQuery Ajax, and all the cases I received the same error.
I almost forgot telling you, this issue only happens if I create a instance to Period attribute. If I return the object clear, I don't have any issue.
I share to you a test I made based on the original code. I hope you could help me.
WCF Service
using MercSoft.Conservatorio.DataModels;
using MercSoft.Conservatorio.Request;
using MercSoft.Conservatorio.Response;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
namespace Mercsoft.Conserv.WSv2
{
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Conservatorio
{
// To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)
// To create an operation that returns XML,
// add [WebGet(ResponseFormat=WebMessageFormat.Xml)],
// and include the following line in the operation body:
// WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
[OperationContract]
public void DoWork()
{
// Add your operation implementation here
return;
}
[OperationContract(Name = "EstaActivo"), WebGet]
public bool isActive()
{
return false;
}
[OperationContract(Name="PruebaOro"), WebInvoke(Method="POST", ResponseFormat= WebMessageFormat.Json)]
public PreRegisterResponse pruebaOro(PreRegisterRequest request)
{
PreRegisterResponse response = new PreRegisterResponse();
response.Period = new ModulesDataModel();
return response;
}
// Add more operations here and mark them with [OperationContract]
}
}
PreRegister Response
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Web;
using MercSoft.Conservatorio.DataModels;
using System.Runtime.Serialization;
using MercSoft.Conservatorio.Request;
namespace MercSoft.Conservatorio.Response
{
[DataContract]
public class PreRegisterResponse : BaseResponse
{
[DataMember]
public PreRegisterDataModel Period { get; set; }
public PreRegisterResponse()
: base()
{
}
}
}
PreRegisterDataModel
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
namespace MercSoft.Conservatorio.DataModels
{
[DataContract(IsReference=true)]
public class SystemPeriodsDataModel
{
[DataMember]
public int Id { get; set; }
[DataMember]
public int PeriodType { get; set; }
[DataMember]
public String PeriodTypeString { get; set; }
[DataMember]
public DateTime? StartDate { get; set; }
[DataMember]
public DateTime? EndDate { get; set; }
[DataMember]
public String DatePeriod { get; set; }
[DataMember]
public bool WithInstument { get; set; } //Pre-register ONLY
[DataMember]
public bool Active { get; set; }
}
}
WebConfig
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="Mercsoft.Conserv.WSv2.Conservatorio">
<endpoint address="" behaviorConfiguration="Mercsoft.Conserv.WSv2.ConservatorioAspNetAjaxBehavior"
binding="webHttpBinding" contract="Mercsoft.Conserv.WSv2.Conservatorio" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="Mercsoft.Conserv.WSv2.ConservatorioAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
I just found the same issue with a piece of code in a WCF service I'm working on, that is (now) using the webHttpBinding (for REST clients). The culprit was the property "IsReference=true" in a DataContract class. I needed that flag set to TRUE because the graph of objects contains circular references; this way the returned response has a lot less bytes than if the real objects were serialized.
I don't know why this works with SOAP and other bindings but not with webHttpBinding, but since I needed to add REST support, the service stopped working when a DataContract class with IsReference=true was being returned.
My temporary solution was to create another class with the same properties as the original, but without the IsReference property. I need to investigate this further but in the meantime I hope this helps.
I'm having trouble with Team Foundation Server 2015 Web Hooks (https://www.visualstudio.com/get-started/webhooks-and-vso-vs)
I can create web hook on TFS side and it successfully uses RequestBin WebService. But when I create the WCF Web service - have errors all the time.
First of all I get #Cannot process the message because the content type 'application/json; charset utf-8' was not the expected type 'text/xml;charset utf-8'.(415)"
I've read a lot of articles and related questions here.
Tried to add Factory="System.ServiceModel.Activation.WebServiceHostFactory" to .svc file. After it I've got 404 error while consuming service and no endpoint found while trying to open it's WSDL
So, my Interface is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace MyService
{
// ПРИМЕЧАНИЕ. Команду "Переименовать" в меню "Рефакторинг" можно использовать для одновременного изменения имени интерфейса "IService1" в коде и файле конфигурации.
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke]
string RollUp(string sData);
// TODO: Добавьте здесь операции служб
}
// Используйте контракт данных, как показано в примере ниже, чтобы добавить составные типы к операциям служб.
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";
[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}
[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}
}
My program is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace MyService
{
// ПРИМЕЧАНИЕ. Команду "Переименовать" в меню "Рефакторинг" можно использовать для одновременного изменения имени класса "Service1" в коде, SVC-файле и файле конфигурации.
// ПРИМЕЧАНИЕ. Чтобы запустить клиент проверки WCF для тестирования службы, выберите элементы Service1.svc или Service1.svc.cs в обозревателе решений и начните отладку.
public class Service1 : IService1
{
public string RollUp(string sData)
{
return "Sucess " + sData;
}
}
}
my web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!--Чтобы избежать раскрытия метаданных, до развертывания задайте следующим параметрам значение "false". -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- Чтобы при сбое получать подробные сведения об исключении для целей отладки, установите для нижеприведенного параметра значение true. Перед развертыванием установите значение false, чтобы избежать раскрытия информации об исключении -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="json">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="MyService.Service1">
<endpoint name="jsonEP"
address=""
binding="webHttpBinding"
behaviorConfiguration="json"
contract="MyService.IService1"/>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
Для просмотра корневого каталога веб-приложения во время отладки установите значение true.
Перед развертыванием установите значение false, чтобы избежать раскрытия сведений в папке веб-приложения.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
And with all of this I get 404 error.
Hope someone can help me as I can't beat this web services for days and for now have no idea what to do.
I am adding objects sent from a client to a list which is at the service, my issue is this, during debugging I see that as soon as i return from the main service to the client the list turns to 0. It's like the list gets emptied and as soon as the flow of the program returns to the client and then when the client sends data to the service the data are there, as soon as i enter the method of the service the list gets filled with the old data. I would like to access these data from another part of the program but i always see the list empty. Any tips?
As per my comment you need to setup the ServiceContract's SessionMode and also the ServiceBehavior's InstanceContextMode. The default InstanceContextMode is PerCall which means that your list will not be preserved. You need to change it to use PerSession. See below for fully working example (.NET 4):
Service Side Code:
using System.Collections.Generic;
using System.ServiceModel;
namespace WcfService1
{
[ServiceContract(SessionMode = SessionMode.Required)]
public interface IService1
{
[OperationContract]
int AddData(string data);
[OperationContract]
List<string> GetData();
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
public class Service1 : IService1
{
private readonly List<string> _myList = new List<string>();
public int AddData(string data)
{
_myList.Add(data);
return _myList.Count;
}
public List<string> GetData()
{
return _myList;
}
}
}
Service Side web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<protocolMapping>
<add scheme="http" binding="wsHttpBinding"/>
</protocolMapping>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
Client Side:
using System;
using System.Collections.Generic;
using ConsoleApplication1.ServiceReference1;
namespace ConsoleApplication1
{
internal class Program
{
private static void Main()
{
using (var service = new Service1Client())
{
// Add items...
int itemCount;
itemCount = service.AddData("Test Item 1");
Console.WriteLine("Service now holds {0} items", itemCount);
itemCount = service.AddData("Test Item 2");
Console.WriteLine("Service now holds {0} items", itemCount);
itemCount = service.AddData("Test Item 3");
Console.WriteLine("Service now holds {0} items", itemCount);
// Get all of the items added...
List<string> listFromService = service.GetData();
foreach (var listItem in listFromService)
{
Console.WriteLine(" * {0}", listItem);
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}
Client Side app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService1" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:59604/Service1.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1"
name="WSHttpBinding_IService1">
</endpoint>
</client>
</system.serviceModel>
</configuration>
Note: I had to ensure that wsHttpBinding was used as basicHttpBinding does NOT support sessions.
THis is the service which I created for Android device to post data but this service doesn't work for me. I called this service through an Android but nothing happens just received an error message of -500 in LogCat. I also check this service on HTTP and SIMPLE REST Client (Google Chrome Extension) but received an error message. Error message is given below. and this service is also published on IIS.
Error Message
The message with Action '' cannot be processed at the receiver,due to a ContractFilter mismatch at the EndpointDispatcher.
This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.
Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None)
These are the params which im passing to the service:
{"mycar":{"Name":"a","Make":"gfgfd ","Model":"web "}}
and here is the service source code
namespace CarSercive
{
[ServiceBehavior(AddressFilterMode=AddressFilterMode.Any)]
public class Service1 : IService1
{
// myCar test = new myCar();
public void UpdateMyCar(myCar mycar) {
string strConnectionString = ConfigurationManager.ConnectionStrings["Database1"].ConnectionString;
SqlConnection conn = new SqlConnection(strConnectionString);
conn.Open();
using (SqlCommand cmd = new SqlCommand("Insert into TestingTable (Name,Make,Model) Values (#Name,#Make,#Model)", conn)) {
cmd.Parameters.AddWithValue("#Name", mycar.Name);
cmd.Parameters.AddWithValue("#Make", mycar.Make);
cmd.Parameters.AddWithValue("#Model", mycar.Model);
int queryResult = cmd.ExecuteNonQuery();
} conn.Close();
}
}
}
web.config
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<compilation debug="true" targetFramework="4.0">
</compilation>
<authentication mode="Windows"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web>
<system.serviceModel>
<services>
<service name="CarSercive.Service1" behaviorConfiguration="web">
<!-- Service Endpoints -->
<endpoint address="" binding="webHttpBinding" contract="CarSercive.IService1"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="web">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
IService1.cs
namespace CarSercive
{
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(
Method = "POST",
UriTemplate = "MyCar",
//BodyStyle = WebMessageBodyStyle.WrappedRequest,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
void UpdateMyCar(myCar mycar);
}
[DataContract]
public class myCar
{
[DataMember(Name = "Name")]
public string Name
{
get;
set;
}
[DataMember(Name="Model")]
public string Model
{
get;
set;
}
[DataMember(Name="Make")]
public string Make
{
get;
set;
}
}
}
You need to add a JSON endpoint to your web.config file.
<system.serviceModel>
<domainServices>
<endpoints>
<add name="JSON" type="Microsoft.ServiceModel.DomainServices.Hosting.JsonEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</endpoints>
</domainServices>
make sure to link to the assembly Microsoft.ServiceModel.DomainServices.Hosting.JsonEndpointFactory in your project
I am trying to create a WCF Restful Service.
Here is my contract: (The ActivateUser class extends the BaseResult class).
namespace SmartShopServerContract {
[ServiceContract]
public interface IService {
[OperationContract]
[WebGet(RequestFormat=WebMessageFormat.Json, ResponseFormat=WebMessageFormat.Json, UriTemplate="au/{eMail}/{password}/{idHandy}")]
ActivateUserResult ActivateUser(string eMail, string password, string idHandy);
}
// Basisklasse der Resultate --> alle Resultate haben einen definierten Status!
[DataContract]
public abstract class BaseResult {
private string status;
public BaseResult(string status) {
this.status = status;
}
[DataMember]
public string Status {
get { return this.status; }
}
}
// Result für ActivateUser
[DataContract]
public class ActivateUserResult : BaseResult {
public ActivateUserResult(string status)
: base(status) {
}
[DataMember]
public string CryptedPassword { get; set; }
}
}
Here is the implementation of the Service:
namespace SmartShopServerService {
public class ServiceSmartShop : IService {
public ActivateUserResult ActivateUser(string eMail, string password, string idHandy) {
return new ActivateUserResult("OK") {
CryptedPassword="testatsa"
};
}
And there is the Web.config file:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat="Json">
</standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
<services>
<service name="SmartShopServerService.ServiceSmartShop" behaviorConfiguration="RESTBehavior">
<endpoint address="/" binding="webHttpBinding" contract="SmartShopServerContract.IService" behaviorConfiguration="SmartShopBehavior"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="RESTBehavior">
<serviceMetadata httpGetEnabled="true" policyVersion="Policy15"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SmartShopBehavior">
<webHttp automaticFormatSelectionEnabled="false"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.5" sku=".NETFramework,Version=v4.5"/>
</startup>
<system.web>
<compilation debug="true"/>
</system.web>
<system.webServer>
<modules>
<remove name="WebDAVModule"/>
</modules>
</system.webServer>
</configuration>
I am testing this with the "VS2012 native tool commant prompt" like this:
svcutil.exe http://localhost:51162/SmartShopService.svc/au/data1/data2/data3
The code is being executed, but I am still getting a Method not allowed (405) exception.
Any thoughts on that?
--> currently local use
--> IIS Express (Visual Studio 2012)
You're using svcutil to create a proxy for a "RESTful WCF service". This does not work. The quick reason is that Web endpoints do not expose metadata for the svcutil tool to know what requests it needs to send to it. The long version is on the linked blog post.
The problem was the base class (BaseResult) for the ActivateUser class --> BaseResult
It seems like that it is not possible to extend a DataContract class and expect it to work.
Now i am using a Interface instead of a base class
public interface IResult {
string Status{get;set;}
}
[DataContract]
public class ActivateUserResult : IResult {
[DataMember]
public string CryptedPassword { get; set; }
[DataMember]
public string Status { get; set; }
}
This is working....thats all i know ;)