do I use MsmqIntegrationBinding or netMsmqBinding? - wcf

my company bought a third party application. There's no documentation, there's no support. this application is using .net, and it creates a queue.
I need to write an application to pick up the message as soon as it gets to the queue.
which binding I should use? I read the difference between these two binding. still confused which one to use.

This decision must be depend on your third party application. NetMsmqBinding used full only if you have both side WCF application. If your application push message without WCF then you have to go ahead with MsmqIntegrationBinding.

Related

NServiceBus and WCF, how do they get along?

Simplified... We are using NServiceBus for updating our storage.
In our sagas we first read data from our storage and updates the data and puts it back again to storage.The NServicebus instance is selfhosted in a windows service. Calls to storage are separated in its own assembly ('assembly1').
Now we will also need synchronous read from our storage through WCF. In some cases there will be the same reads that were needed when updating in sagas.
I have my opinion quite clear but maybe I am wrong and therefore I am asking this question...
Should we set up a separate WCF service that is using a copy of 'assembly1'?
Or, should the WCF instance host nservicebus?
Or, is there even a better way to do it?
It is in a way two endpoints, WCF for the synchronous calls and the windows service that hosts nservicebus (which already exists) right now.
I see no reason to separate into two distinct endpoints in your question or comments. It sounds like you are describing a single logical service, and my default position would be to host each logical service in a single process. This is usually the simplest approach, as it makes deployment and troubleshooting easier.
Edit
Not sure if this is helpful, but my current client runs NSB in an IIS-hosted WCF endpoint. So commands are handled via NSB messages, while queries are still exposed via WCF. To date we have had no problems hosting the two together in a single process.
Generally speaking, a saga should only update its own state (the Data property) and send messages to other endpoints. It should not update other state or make RPC calls (like to WCF).
Before giving more specific recommendations, it would be best to understand more about the specific responsibilities of your saga and the data being updated by 'assembly1'.

WCF Data Service whose data source is another WCF Data Service

does someone know if it possible to use one WCF Data Service as data source of another WCF Data Service? If so, how?
So the short answer is yes. Actually I have consumed one WCF service in another (HttpBinding coming to a service on computer, then that service had a NamedPipesBinding service to communicate with multiple desktop apps, but it did some data transformation in the middle). That would not be an issue at all, you would set up a proxy/client just like you would in a desktop client, and handle everything in your new service as if it was just passing information along, you could even create a shared library for the DataContracts and such.
HOWEVER I would not suggest the leapfrog method in your implementation. Depending on how many customers you are potentially opening the door too, you may be introducing a bottlekneck, if you have a singleton service, or overload your existing service in the case of many connections from the new one. Since you have a SQL server, why would you not have a WCF service on your web/app server (public) that connected to it and provided the data you need? I'm only thinking this because your situation can become exponentially complicated when you start trying to pass credentials for authentication and authorization between the two, depending on your security settings. Another thing to consider is the complexity in debugging this new service and the old one, and a client at the same time, as if it wasn't a pain just to do server and client, since you are opening it to a public facing port, there are different things to set up, and debugging everything on the same machine is not the same as a public facing application server.
Sorry if this goes against what you were hoping to hear. I'm just saying that it is possible, but not suggested (at least by me) in your particular case.

add a check before hitting a WCF service [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
WCF API Deployment Versioning
I am working on WCF Rest services. I have several services.
Now, before a client hits a service, I want to add a check viz. a version number.
If the version number is less than, suppose 2.0, then client application should get an error "Application is outdated" and it should not hit the service.
My main purpose is, I dont want to apply this check in each webservice. I want some generic service which would first check the version and then only allow the client to hit the desired service.
How can this be done.
Also, whether this is possible in classic Webservices in .NET.
I think this is a pretty bad idea - you would need to create a centralised service which somehow knew all the version details of all your service endpoints, and then require your consumers to make an extra call in order to consume your services.
This creates a single point of failure in that if the "Version Checker" service is unavailable then "valid" consumers (ones with the correct client version) will still be unable to call your services.
Also you would need to maintain the current version of each of your services in this central location, which generates support overhead.
The best way of versionning your services is to try to make non-breaking changes so that older versions of the clients can be supported. You an do this in many ways. I have posted about this before here and here.
If you must make breaking changes then you either need to let your consumers break (and therefore be forced to upgrade) or you co-host different versions of your services at different endpoints.
NOTE: There is something which is kind of designed for what you are thinking of, called UDDI. The idea behind a UDDI server is it can store all the information about your services, including endpoint address, transport and even your exposed types, so that consumers can query the UDDI at runtime and assemble a client on-the-fly.
This would result that your consumers need to have absolutely no knowledge of your service version at all, and would retrieve this information at runtime from UDDI.
However UDDI is rarely used (probably for the same reason that it introduces a single point of failure). I have used it exactly once in my career when I built an ESB for a client.
EDIT
In response to your comment, I think the best solution for you would be to expose a Version member on your service operation request contract type which would require consumers to declare which version of the service they are expecting to call.
When the request is received, you can interrogate the request and check the version. If they don't match then you can throw an exception of a type you have defined in a FaultContract. (more about fault contracts here).
This will enable your consumers to wrap the service operation call in a catch block and handle the custom exception type passed back. I don't think there are any built in exceptions which cover "invalid version" errors so you will need to define your own.
This means that consumers will only get an exception back when they try to call your service with an outdated version attribute and avoids having to make an extra service call. Also it distributes this information rather than centralising it (which is more robust approach).
EDIT 2
In response to your comments, Fault contracts are not supported in asmx. You will have to throw the exception on the service and then on the client catch the exception as a SoapException. On the client you then have to interrogate the SoapException message (not nice) in order to work out if it's because of versionning.

WebHttpBinding and Callbacks

I have asp.net site where I call my WCF service using jQuery.
Sometimes the WCF service must have an ability to ask user with confirmation smth and depend on user choice either continue or cancel working
does callback help me here?
or any other idea appreciated!
Callback contracts won't work in this scenario, since they're mostly for duplex communication, and there's no duplex on WebHttpBinding (there's a solution for a polling duplex scenario in Silverlight, and I've seen one implementation in javascript which uses it, but that's likely way too complex for your scenario).
What you can do is to split the operation in two. The first one would "start" the operation and return an identifier and some additional information to tell the client whether the operation will be just completed, or whether additional information is needed. In the former case, the client can then call the second operation, passing the identifier to get the result. In the second one, the client would again make the call, but passing the additional information required for the operation to complete (or to be cancelled).
Your architecture is wrong. Why:
Service cannot callback client's browser. Real callback over HTTP works like reverse communication - client is hosting service called by the client. Client in your case is browser - how do you want to host service in the browser? How do you want to open port for incoming communication from the browser? Solutions using "callback like" functionality are based on pooling the service. You can use JavaScript timer and implement your own pooling mechanism.
Client browser cannot initiate distributed transaction so you cannot start transaction on the client. You cannot also use server side transaction over multiple operations because it requires per-session instancing which in turn requires sessinoful channel.
WCF JSON/REST services don't support HTTP callback (duplex communication).
WCF JSON/REST services don't build pooling solution for you - you must do it yourselves
WCF JSON/REST services don't support distributed transactions
WCF JSON/REST services don't support sessionful channels / server side sessions
That was technical aspect of your solution.
Your solution looks more like scenario for the Workflow service where you start the workflow and it runs till some point where it waits for the user input. Until the input is provided the workflow can be persisted to the database so generally user can provide the input several days later. When the input is provided the service can continue. Starting the service and providing each needed input is modelled as separate operation called from the client. This is not usual scenario for something called from JavaScript but it should be possible because you can write custom WebHttpContextBinding to support workflows. It will still not achieve the situation where user will be automatically asked for something - that is your responsibility to find when the popup should appear and handle it.
If you leave standard WCF world you can check solutions like COMET which provides AJAX push/callback.

webservice to WCF

we had developed a webservice in vb.net,framework 2.0. We would need to rewrite this
websevice in WCF with framework 3.5. Please provide some guidance regarding this and also
there are many othersystems consuming our webservice url. Will this conversion have impact on the source system or does it involve any build activity for the source system to consume the url that will be developed with WCF method?
Please provide sample example to have better understanding on this. Thanks!
A few thoughts.
Case 1: Your webservice is having consumers and you want to rewrite only the service and not disturb the consumers.
In this case using a basicHttpBinding end point with regular wcf service implementation would do. You can find many references to build WCF service with basicHttpBinding. Most probably this would fit your need.
Follwoing links may be helpful to you.
http://msdn.microsoft.com/en-us/library/aa480190.aspx
http://msdn.microsoft.com/en-us/library/ms731361(v=VS.90).aspx
Case 2: If You want to rewrite the service, and it is acceptable to have changes in the consumers, then it is worthy to consider the following points.
Endpoint Choice
a. If your preference is to keep your service interoperable (i.e. you would like the service to serve different platforms), Soap based endpoints would help. basicHTTPBinding, wsHTTPBinding, etc.
b. If your consumers are in the windows platform, and you prefer better performance than SOAP based bindings, netTCPBinding based endpoints would help.
c. If your consumers are in the same machine, netNamedPipe can would be a choice.
Service Design
The service design offers you to go with a lot of combination of the following.
a. Choice of deciding the service instance's life cycle.
b. Choice of Concurrency.
c. Choice of Sessions, and enforcing the order in which the service has to be called (prefered by specific designers)
d. Choice of having or not having the transactions.
You shouldn't need to change anything. It should work the same.
Have you tried migrating it yet? If so, what were the problems? If not, just switch it to 3.5 and see what happens.
The Only need is to change the service endpoints in WCF service making as
http://localhost/YourProjectName/Servicename.svc ,
Without changing the Server Side coding , You
need to expose the Remote Interfaces making them as [Service Contract] and the Methods as [Data Contract] on the client Side