This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyRequestResponseFactory : IMyRequestResponseFactory | |
{ | |
public TResponse ProcessRequest<TResponse>(Request request, Func<TResponse> handler) | |
where TResponse : Response, new() | |
{ | |
try | |
{ | |
// Validacija request poruke (ovisno o tipu) | |
// Autentifikacija korisnika - podaci iz request poruke | |
// Autorizacija korisnika - podaci iz request poruke |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyServiceSample : IMyServiceSample | |
{ | |
private readonly IMyRequestResponseFactory _factory; | |
public MyServiceSample(IMyRequestResponseFactory factory) //dependency injection via constructor | |
{ | |
_factory = factory; | |
} | |
public MyServiceSample() // WCF poziva default konstruktor, i koristimo default implementaciju |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see more at: https://github.com/JeremySkinner/FluentValidation | |
using FluentValidation; | |
public class CustomerValidator: AbstractValidator<Customer> { | |
public CustomerValidator() { | |
RuleFor(customer => customer.Surname).NotEmpty(); | |
RuleFor(customer => customer.Forename).NotEmpty().WithMessage("Please specify a first name"); | |
RuleFor(customer => customer.Discount).NotEqual(0).When(customer => customer.HasDiscount); | |
RuleFor(customer => customer.Address).Length(20, 250); | |
RuleFor(customer => customer.Postcode).Must(BeAValidPostcode).WithMessage("Please specify a valid postcode"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ ServiceHost Language="C#" Debug="true" Service="MyServiceLibrary.MyServiceSample" %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Global : System.Web.HttpApplication | |
{ | |
protected void Application_Start(object sender, EventArgs e) | |
{ | |
Log.Info("Application_Start"); | |
} | |
protected void Application_Error(object sender, EventArgs e) | |
{ | |
var error = Server.GetLastError(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<!-- | |
For more information on how to configure your ASP.NET application, please visit | |
http://go.microsoft.com/fwlink/?LinkId=169433 | |
--> | |
<configuration> | |
<!-- | |
For a description of web.config changes for .NET 4.5 see http://go.microsoft.com/fwlink/?LinkId=235367. | |
The following attributes can be set on the <httpRuntime> tag. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WcfDynamicSoapProxy<T> : IDisposable where T : class | |
{ | |
public static WcfDynamicSoapProxy<T> CreateProxy(string endpointAdressUri) | |
{ | |
return new WcfDynamicSoapProxy<T>(endpointAdressUri); | |
} | |
protected readonly ChannelFactory<T> DynamicChannelFactory; | |
public T Channel { get; private set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var service = WcfDynamicSoapProxy<IMyServiceSample>.CreateProxy("http://localhost:53920/MyServiceSample.svc/soap")) | |
{ | |
var response = service.Channel.DoSomeWork(new SomeWorkRequest(new { Param1=1, Param2="bla“})); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({ | |
url: "http://localhost:53920/MyServiceSample.svc/json/DoSomeWork?request=" + | |
JSON.stringify({ Param1: 1, Param2: "bla"}) | |
contentType: "application/json", | |
dataType: "json", | |
type: "GET", | |
success: function(data) { | |
if (data.success) { | |
// do some stuff... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bindings> | |
<webHttpBinding> | |
<binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" /> | |
</webHttpBinding> | |
</bindings> | |
<!-- JSONP Endpoints --> | |
<endpoint address="jsonp" binding="webHttpBinding" bindingConfiguration="webHttpBindingWithJsonP" | |
behaviorConfiguration="jsonBehavior" contract="MyServiceLibrary.IMyServiceSample" /> |