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
[ServiceContract] | |
public interface IMyServiceSample | |
{ | |
[OperationContract] //soap xml | |
[WebGet(ResponseFormat = WebMessageFormat.Json)] //json | |
bool DoSomeWork(int param1, string param2); | |
// … |
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
[DataContract] | |
public class Result | |
{ | |
[DataMember] | |
public bool Success { get; set; } | |
} | |
[DataContract] | |
public class SomeWorkParams | |
{ |
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
[DataContract] | |
public class Response | |
{ | |
[DataMember] | |
public bool Success { get; set; } | |
} | |
[DataContract] | |
public class Request | |
{ |
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
[DataContract] | |
public class Response | |
{ | |
[DataMember] | |
public List<ResponseError> Errors { get; set; } | |
[DataMember] | |
public List<string> Warnings { get; set; } | |
[DataMember] |
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 : WcfBaseService, IMyServiceSample | |
{ | |
public DoSomeWorkResponse DoSomeWork(SomeWorkRequest request) | |
{ | |
return new DoSomeWorkResponse(); | |
} | |
public DoSomeOtherWorkResponse DoSomeOtherWork(SomeOtherWorkRequest request) | |
{ | |
return new DoSomeOtherWorkResponse(); |
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
[WcfErrorHandler] // custom atribut koji imeplementira IErrorHandler, logiranje sistemskih WCF grešaka | |
public abstract class WcfBaseService | |
{ | |
protected WcfBaseService() | |
{ | |
if (OperationContext.Current == null) return; // ako WCF ne postoji, izađi odmah | |
WcfUtils.LogRequest(); | |
} | |
} |
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 void LogRequest() | |
{ | |
if (OperationContext.Current == null) return; | |
string msg = String.Empty; | |
if (Properties.ContainsKey(RemoteEndpointMessageProperty.Name)) | |
{ | |
RemoteEndpointMessageProperty remote = | |
Properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; | |
if (remote != null) |
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 WcfErrorHandler : IErrorHandler | |
{ | |
public bool HandleError(Exception error) | |
{ | |
return false; | |
} | |
public void ProvideFault(Exception error, MessageVersion version, ref Message fault) | |
{ | |
if (error == null) |
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
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] |
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 interface IMyRequestResponseFactory | |
{ | |
TResponse ProcessRequest<TResponse>(Request request, Func<TResponse> handler) | |
where TResponse : Response, new(); | |
} |
OlderNewer