Eduardo Lorenzo 10-23-2006, 02:22 AM OK, I really don't know where to post this so I put it here in the General location. Mods, please do feel free to transfer this anywhere but the recycle bin.
The situation is this, I am using ASP.Net running Version 1.1 to build a web application for my company. And I have followed (at least I think I did) an architecture that I have read on the web.
My architecture/structure right now is like this:
1. The pages (client) mostly contains code that is just for the presentation of the data, input validation and other things.
2. All data manipulation like inserting and updating are done through Stored Procedures stored in the database. (Oracle 8i)
3. All other procedures and functions are created and saved as classes. I even have something that I call a "data massager" that will tweak the data depending on "who" or which page calls for the data.
The project is almost finished and is getting ready for deployment when they decided to put all the webpages in one server, all the .net procedures and functions in a separate server and the data and PL/SQL procedures and functions in another server. Kinda like having a separate server for the application and the data?
Then after that, they just left it all in my hands to deploy the project in this environment/architecture or whatever it is called.
So there is my problem. I have absolutely no idea how to do this? I mean how do I change my code so that it points to each of the servers? Do I have to change the connection string? what other changes should be made?
Thanks in advance for any and all help on this matter and more power.
sheeesh! what a way to start a monday!?? :(
shaul_ahuva 10-23-2006, 07:36 AM What they are essentially asking for is an n-tier (http://msdn2.microsoft.com/en-us/library/ms973829.aspx) architecture - the goal of n-tier architecture is to distribute the workload so that no one server is doing too much work.
Although it's usually best to design for a specific architecture from the beginning (i.e. deployment is the WRONG TIME to suggest something like this - the architecture should have been determined when the requirements were defined), you should be able to make use of .NET remoting to make your application distributed without too many code changes.
In a nutshell, remoting allows you to define where remote objects are located via a config file; whenever a new remote object instance is created, the framework automatically sets up the necessary plumbing for you. The big benefit in this case is that your client code (your ASP.NET pages) shouldn't need to change very much and the other .NET objects can be hosted by a Windows Service (which is fairly easy to create with .NET). For more on remoting, just search for "remoting" on Google or MSDN.
Eduardo Lorenzo 10-25-2006, 10:55 PM thanks.. yeah, The suggestion was out of timing (to put it mildly), and I have done a little bit of reading also on the n-tier architecture and it seems that its not as easy as a click of a mouse tho..
I have read about using XML web services and am looking into it. Ai actually found some materials on remoting but thought it was somthing like desktop remoting so I skippe it. Will check into it as soon as I finish my lunch...
Thank you very very much for the reply. I will post links on the things about this architecture and n-tier asap.
Eduardo Lorenzo 11-13-2006, 02:46 AM ok.. so now I have made a webservice.. and I am of course using it now although still at the development stage.
But I have hit a roadbump and here it is:
I want to expose properties from my asmx file, something to this effect
Public ReadOnly Property CurrentParameters() As SqlClient.SqlParameterCollection
Get
Return cmdsqlCmd.Parameters
End Get
End Property
Public ReadOnly Property ErrorMessage() As String
Get
ErrorMessage = err
End Get
End Property
this is because i have these functions also exposed
<WebMethod()> Public Sub AddInputParameter(ByVal Name As String, ByVal Value As Object)
Dim parsqlParam As SqlParameter
parsqlParam = New SqlParameter
With parsqlParam
.ParameterName = Name
.Direction = ParameterDirection.Input
.Value = Value
End With
cmdsqlCmd.Parameters.Add(parsqlParam)
parsqlParam = Nothing
End Sub
<WebMethod()> Public Sub AddOutputParameter(ByVal Name As String, ByVal Value As Object, ByVal Direction As ParameterDirection)
Dim parsqlParam As SqlParameter
parsqlParam = New SqlParameter
With parsqlParam
.ParameterName = Name
.Direction = ParameterDirection.Output
.Value = Value
End With
cmdsqlCmd.Parameters.Add(parsqlParam)
parsqlParam = Nothing
End Sub
and these
<WebMethod()> Public Function getremitterlist(ByRef target As DataSet, ByVal paramname As String, ByVal paramvalue As String) As Boolean
all I could do was to make this
<WebMethod()> Public Function errormsg() As String
Return err
End Function
but I am sure (somewhat) that there should be a tag to add to the public properties so it can be exposed.
I tried the <xmlserialization()> and <xmlignore()> and the <xmlelement()> tags but they didnt work.
Eduardo Lorenzo 11-13-2006, 02:50 AM another "caveman" question..
is the webservice really limited to just passing (in concept) only a dataset? :mad:
I want to be able to pass a PropertyCollection object.. :D
shaul_ahuva 11-13-2006, 06:31 AM The <WebMethod> attribute can only be applied to methods - it can't be applied to properties.
You shouldn't approach web services as objects with instance properties and methods (state) since web services aren't really designed for stateful requests, although you could design it this way if desired. They're intended more for stateless requests where the web method(s) take objects as parameters, work with/perform operations on the objects and return a result (be it the objects or something else).
For example, if you want to prepare a database command and execute it via a web service (not exactly the best design for a number of reasons, but that's a topic for another thread) it would make more sense to create a custom type that describes the command and parameter(s):
<Serializable()> _
Public Class DbCmd
<Serializable()> _
Public Class Parameter
Public Name As String
Public Value As String
End Class
Public CommandText As String
Public Parameters As ArrayList
End Class
Then, create a new instance of the above type and populate it with data the server will need to then process the object:
<WebMethod(), _
XmlInclude(GetType(DbCmd.Parameter))> _
Public Function ExecuteCommand(cmd As DbCmd) As DataSet
'Process cmd and return the result...
End Function
That being said, my suggestion for you would be to create web methods that perform a single operation (i.e. a customer web service would implement methods such as GetCustomerList, GetCustomer, UpdateCustomer, and DeleteCustomer).
You can pass an object of any serializable type (any type marked with the <Serializable> attribute) through a web service, although you may need to add the <XmlInclude> attribute on the web method(s) so that ASP.NET knows what types to expect.
Eduardo Lorenzo 11-13-2006, 04:49 PM You shouldn't approach web services as objects with instance properties and methods (state) since web services aren't really designed for stateful requests, although you could design it this way if desired.
I decided to stick with this to avoid complications. My web service now has functions that passes the parameters to the business layer..
You can pass an object of any serializable type (any type marked with the <Serializable> attribute) through a web service, although you may need to add the <XmlInclude> attribute on the web method(s) so that ASP.NET knows what types to expect.
such as? as of now all I know is that the webservice can handle only a dataset. I used to use a PropertyCollection which was filled up by the client page and sent to the business and datalayer.
is an arraylist advisable?
thank you very much for the guidance.. please bear with me because I shall have a whole lot more questions when its time to deploy this software.
Question/Complaint:
At present, I have constructed the client, web service, business layer and data layer as different projects and combined them in one solution.
Do really have to Delete the Web Reference and add it again so that changes in the web service (.asmx file) shall be made available during design time? :mad:
this is maddening!
Eduardo Lorenzo 11-14-2006, 04:35 PM ok.. here is where I am right now..
I have accepted that the webservice can only pass a dataset. So as to avoid using other tags such as serialization.
Now that I have to pass a set of values to the data layer for an insert.. do I have to
Create a dataset with a datatable and populate it with the values on the page and then pass this through the webservice to the bussiness and then to the data layer?
is there an alternative?
shaul_ahuva 11-14-2006, 06:27 PM I decided to stick with this to avoid complications. My web service now has functions that passes the parameters to the business layer..
I pointed this out because it looks like the "cmdsqlCmd" variable is an instance field on the web service itself. This is a big problem because you get a new web service instance for each request (web method call), so you'll be working with different command object instances. As I said, web methods should be treated as stateless and not stateful. If you want to keep state on the server between requests, you should use Session to store data for the current session.
such as? as of now all I know is that the webservice can handle only a dataset. I used to use a PropertyCollection which was filled up by the client page and sent to the business and datalayer.
System.Data.PropertyCollection is serializable, so you should be able to pass a PropertyCollection instance without any extra <XmlInclude> tags.
Do really have to Delete the Web Reference and add it again so that changes in the web service (.asmx file) shall be made available during design time?
You should be able to right-click on the web reference(s) and choose "Update Web Reference".
Create a dataset with a datatable and populate it with the values on the page and then pass this through the webservice to the bussiness and then to the data layer?
is there an alternative?
You can also pass a single DataTable (if that will suffice), or you can create your own type to encapsulate the values that need to be sent.
Eduardo Lorenzo 11-14-2006, 07:24 PM System.Data.PropertyCollection is serializable, so you should be able to pass a PropertyCollection instance without any extra <XmlInclude> tags.
I got this "Server was unable to process request. --> Method remitter.savedata can not be reflected. --> There was an error reflecting 'saveprop'. --> The type System.Data.PropertyCollection is not supported because it implements IDictionary."
You should be able to right-click on the web reference(s) and choose "Update Web Reference".
I did.. the IDE crashed.. :mad: :D :D
and I clicked "Don't Send" :D
You can also pass a single DataTable (if that will suffice), or you can create your own type to encapsulate the values that need to be sent.
haven't tried this yet.
|