I am going through the transactions exist in wcf service but seeking some more clarification on this. I am not sure about which transaction manager wcf will use fo r following scnarios
1) If the wcf service is performing insert in table of one sql server database and delete from table of another sql server database(In same or different server)
2) If the same wcf service is performing insert in table of one sql server database and delete from table oracle database.
3) If wcf service calling 2 different wcf service performing operation on same sql server base database.
Kindly help me providing some understanding on this situations
Please refer to the following tutorials:
http://www.codeproject.com/Articles/570915/TutorialplusonplusUnderstandingplusTransactionsplu
http://www.codeproject.com/Articles/38793/Steps-to-Enable-Transactions-in-WCF
Related
In our software clients can create multiple (Sybase SQL Anywhere) databases (Administrations). They all share the exact same schema and have all the same database objects, for example stored procedures.
Many of our customers have asked to write directly into these databases (to write their own custom software), but we have a closed database (thus users don't have direct data access) policy to prevent corrupt data entry.
As a workaround, I thought about writing a webservice host. Via this host, I would like to execute stored procedures.
I was thinking of using WCF services as this gives me a nice WSDL-definition, but my company rather sees me using the same concepts as other projects in our company (due to standardization), so it should use WebAPI and/or Owin.
To explain where I want to go, here's some info:
I have two identical databases, CorpDb and SchoolDb. Both have the same (simplified) procedure CreateCustomer which take parameters CustId, CustName and CustAddress.
Via this service host, I want to be able to accept requests that specify the following parameters: database filename, stored procedure to execute and the parameters to the procedure. I have no idea on how to send these parameters, but they could be:
database=corpdb
proc=createcustomer
params=(CustId=DummyCorp,CustName=Dummy Corp
International,CustAddress=Cloud 9)
The questions that keep me busy:
Is this a good or bad idea, and if it's a good one, how do I set it up?
How do I process the incoming requests? which format request should I use, and is there something simular to WCF's SOAP message to help me create proxy classes for the customers who want to build their own custom software using our webservices. How will they connect to this host in their software? and can I call the stored procedures from within the host directly?
I am sorry if this is (too) vague, but I am not very experienced in build webservers or webservices. If needed, I will clarify stuff. Thanks for reading.
Regards, Ted
Our company needs to write a web service which will use to submit data from remote site to HQ Servers. This web service will update more then 10 tables from both site(Remote and HQ).
We use SQL Server 2008 in both sides and one batch, will insert data into HQ Server and at the same time need to do some updates on the remote side as well.
The remote site will call the web service on HQ with required data.
Simply I need to commit or roll-back both servers when the web method executed.
What is the best way to handle the transaction block in this situation?
I am going through the transactions exist in WCF service but seeking some more clarification on this. I am not sure about which transaction manager WCF will use for following scenarios:
If the WCF service is performing insert in table of one SQL server database and delete from table of another SQL server database (in same or different server)
If the same WCF service is performing insert in table of one SQL server database and delete from table oracle database.
If WCF service calling 2 different WCF service performing operation on same SQL server base database.
Kindly help me providing some understanding on this situations.
I think you're giving WCF more credit than it's due. WCF can do some amazing stuff, but there's nothing magical about it. It provides a set of interfaces for web services and allows you to provide an intermediary access layer for your data.
So let's tackle your scenarios:
If the WCF service is performing insert in table of one SQL server database and delete from table of another SQL server database (in same or different server)
We've got two RDBMS in use here, so you're going to have two transaction managers. The first transaction manager is in the RDBMS for the insert, and the second transaction manager is for the delete.
If the same WCF service is performing insert in table of one SQL server database and delete from table oracle database.
Again, we've got two RDBMS in use here, so you're going to have two transaction managers. The first transaction manager is in the RDBMS for the insert, and the second transaction manager is for the delete.
Note that we don't need to care about which type of RDBMS it is, we just track the number that are involved.
If WCF service calling 2 different WCF service performing operation on same SQL server base database.
This one is a little trickier because we don't know what the 2 WCF services are doing, and there is some unadvisable voodoo magic that could be done to coordinate transactions across the 2 services. I'm going to assume you're smarter than that and didn't mean that case.
So in this case, we have 1 RDBMS performing 2 separate transactions. We'll have 1 transaction manager from the 1 RDBMS, but the operations will complete under different transactions.
To wrap that up - to know how many transaction managers are involved, you need to look at the number of RDBMS that are being used. And to know how many transactions will be required, you need to look at the number of operations performed.
Notice that the use of WCF has no bearing on your concern about the managers. WCF just happens to be a tool that provides an additional way of accessing the data through a service. WCF is cool, but it's not magic.
Additional note
You asked in a comment:
my concern is that in all of this condition which transaction manager it will use a) The LTM b) The KTM c) The DTC?
And for the MS SQL Server transactions, it will either be the LTM or the DTC that handles the transaction. Per this MSDN Blog entry, it's not necessarily something you need to worry about until performance becomes a significant issue. And you should avoid premature optimization in favor of getting things working first.
And based upon this description of the KTM, it's very unclear how you think you'd be using the KTM in any of the cases you asked about.
The Kernel Transaction Manager (KTM) enables the development of applications that use transactions. The transaction engine itself is within the kernel, but transactions can be developed for kernel- or user-mode transactions, and within a single host or among distributed hosts.
Also note that Oracle DB has a separate transaction manager for its RDBMS that is different than the MS SQL Server transaction manager(s).
I'm trying to make a login app.
I would like to know how the connectionString on app.config is made for an online connection and if I would need anything else to reach the database, being as I'm trying to go directly to the user table on that database and perform a check for the login (as I already made it happen with a local database)
Best Regards
Your online database, does that mean a database at a remote location?
I would advise against going directly to a remote database unless that database server is protected in a LAN environment with no outside public access. Public access would also be considered if users inside the LAN also have unregulated access to the remote server. In any thick click based application the typical architecture would be to go through a proxy source or set of WebServices to authorize and authenticate users. Direct access opens your SQL server up to remote attacks.
That being said the connection string to an SQL server (remotely) could be:
Standard User\Pass
Server=myRemoteServer;Database=myDataBase;User Id=myUsername;
Password=myPassword;
Now chances are there are firewalls between the remote database and your client APP protecting remote logins (as there should) and it is a good possiblity that SQL server has disabled remote logins. Read here for more http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx
I must point out again that this is a very bad idea and I would personally create a set of WCF WebServices to run on the server with the database. The WCF services would be responsible for connecting to the database to verify the credentials and return a structured datamodel.
WPF Applications are designed to work really well with the Async methods of WCF services and are very simple to setup. Using this model you can also setup more advanced layers of authentication using hashed token sets, implement SSL to block sniffing out the plain text, and keep your database protected from external access.
There are alot of examples on the web to connect to WCF services from a WPF application.
I am developing a businees application, which queries lots of record.
Which connectivity is good to retrieve?
1. LINQ to SQL or
2. LINQ to Entity or
3. RIA Service or
4. Others ?
Your help is greatly appreciated.
If you're creating a WCF service to expose a database to other programs, you could try WCF Data Services. With this, consumers of your service can use LINQ syntax to send complex queries to the service, which will execute them on the database and return the results REST-style, formatted in an XML dialect called OData that can be read by any XML parser--or transparently read and converted into objects by a WCF Data Services client.