i have a rails app must consume wcf services provided by asp.net, are there any ruby clients for wcf?
Are you in control of the web service? Can you change the web.config a bit? (You indicate Asp.Net so I guess that means the WCF Service is hosted in IIS.)
A WCF service can be exposed as a regular old web-service. It's one of the promises of WCF: the same service can be exposed via many bindings with nothing but a configuration change.
<endpoint address="" binding="basicHttpBinding" contract="IServiceContract">
Then you can call it from Ruby like so:
require 'soap/wsdlDriver'
soap = SOAP::WSDLDriverFactory.new("http://host/SomeService.svc?wsdl").create_rpc_driver
soap.ServiceMethod(:param1=> Value, :param2 => AnotherValue)
Related
I have a multilayer asp.net mvc application consisting of the following levels:
Database (with stored procedures, views and tables)
WCF service (containing business logic and connection to the database through Entity Framework)
Asp.net mvc application communicating with the WCF service and generating html
Browser
The end-users are authenticated in the asp.net mvc layer using Identity 2.0.
The web server is the only client for the WCF service.
Are there any best-practices for this scenario?
The web server and the WCF service might be running in different locations so we cannot use the intranet protocols.
Since we control both the web server and the WCF service we know that the communication will be point-to-point. This means we can use transport security to avoid the extra overhead with message security.
According to this, Improving Web Services Security: Scenarios and Implementation Guidance for WCF, there are two choices for transport security over internet:
Basic authentication with basicHttpBinding
Certificate authentication with wsHttpBinding
Which one would be best suited to this scenario where there basically is only one client for the WCF service?
Due to the stateless nature of http for each new request to the web server a new service-proxy is instantiated.
Is there a way to cache the authentication info from the WCF service on the calling web server to better performance?
You can set up certificate authentication between your WCF and MVC servers using BasicHTTPBinding ... I've done it. But I'm not sure why you use BasicHTTPBinding when, from your description, all the backend services (WCF and MVC) are Microsoft based.
BasicHTTPBinding is a generic WCF protocol that will accept any properly formatted HTTP request (Gets/Post), whether the request comes from a Windows machine or the JAVA/PHP world. It's also, as you say, stateless. That makes BasicHTTPBinding good for interop situations, but more complex (than say wsHTTPBinding) when setting communication between two MS-centric systems.
By default, for instance, NONE is the default encryption for BasicHttpBinding. Adding Transport takes programming and lot of trial and error to get running, from my experience. BasicHttpBinding, also, doesn't support transactions or sessions while WSHttpBinding does. So, based on your description, WSHttpBinding will be simpler and easier to setup and maintain in the long run. But you might also consider NetTCPBinding since you're going server-to-server.
Below you'll find a great MS site explaining all the different WCF protocols, including to pros and cons of each approach.
http://msdn.microsoft.com/en-us/library/ms730879.aspx
Is it possible to consume WebAPi into windows service. Because WebAPI is http protocol, so iam not sure weather i will consume WebApi.
I tried search for consuming WebAPI with Windows service. I can't even find single examples.
Can any face similar kind of scenario
Yes we can able able to consume WebAPi inside the Windows service. Since it is windows based service we need consume it with HttpClient object.
I have 6 WCF web services in my web application.
On visiting any page on my MVC3 site I may call up to 4 or so of these WCF services.
In my live environment (as in all my environments) I have all my web services hosted on the same machine (each front end server has these services).
My issue is that the site I'm working on runs very slowly and as part of the performance improvements to the site I wanted to reduce the overhead of all these http requests to these various WCF services.
My question is, is it possible to call these web services in a 'non-http-overheady' way since they are living on the same machine anyway?
Thumb rules in choosing endpoint' binding of WCF
If you require your service to be consumed by clients compatible with
SOAP 1.1, use basicHttpBinding for interoperability
If you require your service to be consumed within the corporate
network, use netTCPBinding for performance
If you require your service to be consumed over the internet and the
client is a WCF compatible, use wsHttpBinding to reap full benefits
of WS* specifications
If you require your service to be accessible only in the same machine, use netNamedPipeBinding
If you require your service to be queue messages, use netMsmqBinding
If you require your service to act as server as well as client in a
peer to peer environment, utilise netPeerTcpBinding setting
I have a singleton WCF service that owns sockets that are used to communicate with an external party. I am using .NET 3.5 SP1
The code is thread safe and scales well.
When I run this code in a WCF service hosted in IIS 7.5 on Windows 2008 R2 64 bit, the WCF service cannot accept more than one concurrent call.
My service class implements three interfaces, each with a standard ServiceContract attribute and only a namespace, no other settings
I have the following attribute on the class:
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single,
ConcurrencyMode = ConcurrencyMode.Multiple)]
I have the following behavior configuration:
<behavior name="MyServiceAsyncBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceThrottling maxConcurrentCalls="60" maxConcurrentSessions="60"
maxConcurrentInstances="60" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
I created a seperate application, used the exact same configuration file (literally a copy, no changes were made to it), and a singleton service class with the exact same ServiceBehavior attribute on the class. This service DOES NOT exhibit the same behavior, it happily allows concurrent calls.
The only differences between the test service that allows concurrent calls and the real service that does not is that the real service owns worker threads and TCP sockets, and implements three interfaces instead of one.
What am I missing here?
I found the issue. It relates to the remote TCP service. I was using an ill-behaved test service, which never returned to the caller.
WCF seems to have prevented concurrent calls to the singleton because the singleton was locked in a tight loop
can we use WCF in Asp.net MVC and how can we use?
Sure you can - you need to learn the basics, e.g. from this site here:
http://msdn.microsoft.com/WCF
I can't possibly explain all you need to know here - go and learn the basics of WCF, and if you have concrete problems / questions, come and ask them here!
Do you mean, can my ASP.NET MVC projects be WCF clients, or contain WCF servers?
If the former, sure no problem. Right click on Solution Explorer, 'Add Service Reference', enter the URL to a running service (or pick an existing one from within another project in your solution) and away you go.
If the latter, that's fine as well. There is nothing stopping you from adding a WCF service via (perhaps SomeService.svc) 'Add\New Item...' (WCF Service, AJAX-enabled WCF Service, or Silverlight-enabled WCF Service are your options) or by hand. You need to bear in mind that the WCF service in this case will be hosted in IIS so there are some restrictions you need to be aware of depending on which version of IIS you are deploying to (ie. in IIS 6 only HTTP protocols are supported for your WCF services, some of the more esoteric WCF options may also be limited).