WCF workflow service with Ajax - c#

I have a WCF Service, and I need know it ,is possible consume form an ajax client?
The extension of the workflow files that I intend to consume are of type .xaml

WCF Xaml-based WF Services are exposed as SOAP based services, so ajax client can work out, but it would be very difficult to construct the payload. I would recommend to create a thin layer of webapi that can accept json and interact with WCF service.

Related

Can I consume a Web API as you would consume the contract of a WCF service?

Description:
I have an client app consuming a WCF service, both runing on .NET Core and hosted as web apps in Azure.
The client has access to an interface that the service implements as its DataContract.
Currently I consume the service via creating a ChannelFactory based on an DataContract of the WCF service.
Because lots of reasons I'd like to move away from WCF.
My first idea was to convert the WCF service to a Web API and implement something like OpenAPI (Swagger) and from there consume the API via generated docs.
However I can't really find anything similar to the way you would consume a WCF contract and then be able to call upon its methods.
Question:
Is it possible o use a shared interface between the consumer and a Web API in a way that enables me to call upon the methods (routes) in that interface? Be it using OpenAPI (Swagger) or any other framework/lib/or otherwise.
Please let me know if anything is unclear and I'll add info, I'm aware its a somewhat broad question.

WCF Validation - Requiring and validating custom values

We are currently developing some new systems to replace parts of several legacy systems.
We have some new WCF web services which will sit alongside existing ASMX web services.
The ASMX web services authenticate via a Soap Header Context object with 4 custom properties including a token (previously generated and returned at login) which are then validated.
We are not re-writing the validation code yet and the login is still being handled by the existing ASMX services, so we are required to call the existing validator passing in a Context object with the 4 properties from the WCF service application.
How do we capture the 4 properties via the WCF service?
A previous WCF project implemented WCFExtras+ to replicate the Soap Header over WCF.
We can do that again but would prefer a native WCF approach.
I have found options such as custom UserNamePasswordValidator or ServiceAuthorizationManager but have been unable to determine how to exactly apply these to our specific requirements.
Is this possible? How?
After much googling I wrote my own custom behaviour using IOperationBehavior, IContractBehavior and IDispatchMessageInspector

When I Make my (ASMX) web service accept/return JSON instead of XML, is it no longer considered SOAP?

Just trying to wrap my head around SOAP vs REST. We currently have some asmx web services, mostly used between our own JavaScript and server code (not a public API). When I specify my method as a ScriptService and specify a ResponseFormat of Json, is it still considered just a SOAP service? It still doesn't feel RESTful to me, but maybe thats because of the way my "resources" are designed (not well/fully represented by rest).
EDIT: Reading more I might be confusing the format (JSON vs XML) with the fact that most descriptions of the SOAP protocol tie in XML. For example, wikipedia states:
It relies on Extensible Markup
Language (XML) for its message format
To me logically that says if I'm using JSON I must not be using SOAP.
This isn't exactly what you asked, but ASMX services are not RESTful if you're calling them from JavaScript and retrieving JSON. You must make a POST request to ASMX services to get JSON out of them, even if the request is idempotent and only retrieves data. In a RESTful API, a GET request would be used in that case, not POST.
That's not to say that the lack of RESTfulness is an actual problem for a private API. I've found ASMX services as a JSON-based service layer for AJAX callbacks works great in practice.
You define what kind of requests are made to you web service (asmx). Many protocols are allowed:
HTTP POST,
HTTP GET,
SOAP 1.1,
SOAP 1.2,
etc... OR you can block any of them.
When you call the web service with javascript you can use POST or GET. It doesn't matter. The trick is what type of content you tell the service to return in these calls. You can tell the service to send you JSON or you can tell the service to send you XML.
When you create a service client in Visual Studio to connect to a ASMX service, Visual studio will try to access the WSDL for the service and the client will be in charge of generating the SOAP envelopes to communicate with the service and in this case you will send and receive XML because thats what the client and server have agreed to use to communicate.

Can I generate proxy objects for WCF service library using scriptmanager?

I have used the AJAX Enabled WCF Service template from within a web application. By adding a Service reference to the scriptmanager, some client objects are generated allowing me to easily consume the service. My question is can I do anything like that when I use a WCF Service Library? I added the project to my solution and in my web app I added a service reference to the service. This is where I get a bit stuck. What do I do now to allow consuming the service from the client.
So, just to consume wcf service, you have to use "svcutil" app from VS pack to generate o proxy class, which is very simple in usage.

To consume a RESTful web service in C#, should I use HttpWebRequest?

How do I consume a RESTful web service in C# code?
NOTE: by RESTful, I mean non-SOAP. For example, in the flickr API you can call their web service as follows to return JSON data:
http://api.flickr.com/services/feeds/photos_public.gne?tags=cats&tagmode=any&format=json
Do I simply use HttpWebRequest?
What if I'm using a web service that takes POST parameters? Would that use HttpWebRequest also?
Is there any benefit to using WCF on the consumer side?
WCF provides a unified programming model for communication, so if you later decide that you do not want to use REST or you want to provide an extra type of endpoint for example SOAP, you only need tp change the configuration.
Take a look at REST for WCF:
http://msdn.microsoft.com/en-us/netframework/cc950529.aspx
Their is a demonstration and labs in the .NET Framework 3.5 Enhancements Training Kit, which provides two labs based around creating, servicing and consuming RESTFul services. The above link is the best MS combined resources of REST services.
Bob.

Categories