473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Question for all of you EXPERT.NET architects

Question: How do you develop a web service that uses unknown types?

The ideas is that my web service performs a generic function. I want
anyone to be able to consume it, but I can't know what type of objects
they are going to pass to in (like I said it performs some generic
functionality - I don't want to recompile it ever).

So I create a simple web service with with a method like:

string GetTypeInfo(object t){
return t.GetType().ToString();
}

I want to consume it with something like:

string s = WebService.GetTypeInfo(new Widget());

Now the big question:
The Widget type is NOT referenced in the web service (the whole point
is its generic remember). Now to me it makes sense that the client
(web service consumer) would serialize the object to xml, and pass the
xml and xsd describing the object over the wire via soap. The server,
would deserialize the xml to an object using the xsd by doing the
following: if the type is unknown, the deserializer could define a new
type via system.refelection.emit and then create an instance of it and
populate it. Does this make any sense? Is there something built into
the webservices to do this? If not, has anyone tried to roll your
own?

So why would I want to do this? Because lets say you have a business
tier and a data tier that are loosely coupled. My business tier holds
my model and my data tier populates the model (using a persistance
framework like hibernate). I don't want to recompile my data tier
simply because my model changes - I want it to be LOOSELY coupled, but
I don't want to be tied to simple value types and strings (I want to
do something useful).

Thanks for taking to read and answer my question.
Mike
Nov 21 '05 #1
6 1401
Mike Mille wrote:
Question: How do you develop a web service that uses unknown types?


I'm posting my response of list to avoid starting a holy war. I don't
believe in the no-win scenario...

http://sqljunkies.com/WebLog/ktegels...8/04/3768.aspx

Thanks!

Kent Tegels

SQL Sever Express Blog (Good for FAQs): http://tinyurl.com/6r4gb

SQL Server Express BOL (The docs you need): http://tinyurl.com/4ctjx

Kent's Blog: http://www.tegels.org/
Nov 21 '05 #2
Ken the link you sent is not working? I was not trying to start a
holy war just get a answers to a question (the more input the better).
The scenerio I mentioned is just one of many for me and solving this
problem would be huge.

Thanks,
Mike
"Kent Tegels" <ke**@tegels.org> wrote in message news:<#u*************@TK2MSFTNGP10.phx.gbl>...
Mike Mille wrote:
Question: How do you develop a web service that uses unknown types?


I'm posting my response of list to avoid starting a holy war. I don't
believe in the no-win scenario...

http://sqljunkies.com/WebLog/ktegels...8/04/3768.aspx

Thanks!

Kent Tegels

SQL Sever Express Blog (Good for FAQs): http://tinyurl.com/6r4gb

SQL Server Express BOL (The docs you need): http://tinyurl.com/4ctjx

Kent's Blog: http://www.tegels.org/

Nov 21 '05 #3
It appears that both DNJ and SQLJ are down at this time. Give 'em a
couple of hours to sort that out.

Thanks!

Kent Tegels

SQL Sever Express Blog (Good for FAQs): http://tinyurl.com/6r4gb

SQL Server Express BOL (The docs you need): http://tinyurl.com/4ctjx

Kent's Blog: http://www.tegels.org/
Nov 21 '05 #4
You could set up the object, conceivably, by using System.Reflection.Emit,
but you leave a lot of possibilities when you except any type of object.
While you may receive a factory and build your own factory, you might find
that there factory was a mill, while yours looks more like a car factory.

This is not a major problem if you are merely dinking around with the
variables and sending it back in the same serialization method. But, in
those cases, the factory object is a BS concept you made up simply to dink
around with properties. If that is all you are doing, why deserialize the
stupid class anyway, as you can consume the serialized XML and change things
and bounce it back.

Apologies if I appear a bit snarky on this one, but I, like Kent, believe
you should know what your app is doing. If someone wants to fire some
generic BS that you are not going to officially handle, it is better to
leave it as an XML string and store it that way than it is to create a
complete BS object simple to pretend you are talking the same language.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Mike Miller" <mm*****@bluecypress.net> wrote in message
news:f2**************************@posting.google.c om...
Question: How do you develop a web service that uses unknown types?

The ideas is that my web service performs a generic function. I want
anyone to be able to consume it, but I can't know what type of objects
they are going to pass to in (like I said it performs some generic
functionality - I don't want to recompile it ever).

So I create a simple web service with with a method like:

string GetTypeInfo(object t){
return t.GetType().ToString();
}

I want to consume it with something like:

string s = WebService.GetTypeInfo(new Widget());

Now the big question:
The Widget type is NOT referenced in the web service (the whole point
is its generic remember). Now to me it makes sense that the client
(web service consumer) would serialize the object to xml, and pass the
xml and xsd describing the object over the wire via soap. The server,
would deserialize the xml to an object using the xsd by doing the
following: if the type is unknown, the deserializer could define a new
type via system.refelection.emit and then create an instance of it and
populate it. Does this make any sense? Is there something built into
the webservices to do this? If not, has anyone tried to roll your
own?

So why would I want to do this? Because lets say you have a business
tier and a data tier that are loosely coupled. My business tier holds
my model and my data tier populates the model (using a persistance
framework like hibernate). I don't want to recompile my data tier
simply because my model changes - I want it to be LOOSELY coupled, but
I don't want to be tied to simple value types and strings (I want to
do something useful).

Thanks for taking to read and answer my question.
Mike

Nov 21 '05 #5
I guess I am attemping the wrong approach for a service oriented
architecture - although I think I have correct end goals in mind. I
think everything said so far is valid. So is anyone building things
like generic core services for the enterprise that can be consumed by
multiple applications. I am talking about things like logging and
auditing, configuration, search, and persistance. Things every
application needs, but in many cases most don't care how they are
implemented, simply that they work. Most of these services will be
wrapped with functionality in the application to meet the business
requirements, they are simply building blocks to get there faster,
without coping and recompiling the same old code blocks over and over
again. If you are using these types of services how are you passing
data (xml that conforms to a xsd the service publishes)? If your not
what is your approach?

Thanks for all the input-
Mike
Nov 21 '05 #6
Mike, I think you nailed the issue in the first sentence of your most recent
post:

"I guess I am attemping the wrong approach for a service oriented
architecture - although I think I have correct end goals in mind."

SOA is based on the concept of qualified (i.e., well-defined) message
exchange between Web service endpoints. This is not incompatible with your
goals, because SOA does not dictate what the inner workings of a Web service
how. However, SOA does dictate that the messages being exchanged must be
well qualified. This is why you are attempting the wrong approach for SOA.

That being said, why can't you use a more generic, collection-based custom
object to transmit your Web service requests if you really don't want to be
pinned down to specific custom data types. For example, the ADO.NET DataSet
is simply a fancy collection of rows. There's nothing to stop you from
implementing a collection-oriented custom data type that is, say, a
collection of strings, where each string is a particular generic command to
the Web service.

But whichever way you cut it, you will find that you can't clearly explain
to your clients how to call your Web service. If you tell them to pass in a
"generic collection of input parameters" then you leave the door open for
them to make mistakes, to send you improperly formatted Web service
requests, and then things could get ugly! So, my perspective is that SOA's
enforcement of qualified types is ultimately in your favor. And don't
forget, you can always upgrade your Web service interface if the
functionality changes... you just then need to publish 2 different versions
of the WSDL document for the Web service.

Jeffrey Hasan, MCSD
President, Bluestone Partners, Inc.
-----------------------------------------------
Author of: Expert SOA in C# Using WSE 2.0 (APress, 2004)
http://www.bluestonepartners.com/soa.aspx
"Mike Miller" <mm*****@bluecypress.net> wrote in message
news:f2**************************@posting.google.c om...
I guess I am attemping the wrong approach for a service oriented
architecture - although I think I have correct end goals in mind. I
think everything said so far is valid. So is anyone building things
like generic core services for the enterprise that can be consumed by
multiple applications. I am talking about things like logging and
auditing, configuration, search, and persistance. Things every
application needs, but in many cases most don't care how they are
implemented, simply that they work. Most of these services will be
wrapped with functionality in the application to meet the business
requirements, they are simply building blocks to get there faster,
without coping and recompiling the same old code blocks over and over
again. If you are using these types of services how are you passing
data (xml that conforms to a xsd the service publishes)? If your not
what is your approach?

Thanks for all the input-
Mike

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Blackbaud | last post by:
Blackbaud has several permanent, full-time openings in the Product Development department including Software Engineers, Software Architects and Application Developers. All positions are based at...
33
by: John Timbers | last post by:
I'd like to purchase Visual C# .Net for learning purposes only since it's a lot cheaper than Visual Studio (note that I'm a very experienced C++ developer). Can someone simply clarify the basic...
43
by: nospam | last post by:
I got three (3) files (1) Untitled.aspx (2) Untitled.aspx.1.cs (3) Untitled.aspx.2.cs These three files must be used together to make file #1, Untitled.aspx, page work via J.I.T. when the...
62
by: ROSY | last post by:
hello experts plz answer following questions::: thanks in advance. 1. Out of fgets() and gets() which function is safe to use and why? 2. What is a far pointer? where we use it? 3. What does the...
13
by: Ghislain Tanguay | last post by:
I have a compiled vb.net app and I want to give the user a choice to launch it from the start line command and pass it a parameter or not. How can I do that in my code? Is it possible? Ex. :...
1
by: HS1 | last post by:
Hello I use a DataGrid to present data of a table ("Jobs") through a DataSet (ds) using a DataAdapter (da) I use the query for DataAdapter (da):
0
by: TomasFloyd | last post by:
Hi all I'm using VS 2003 and I want to create ERD's that I can forward engineer. My Visio 2003 doesn't support this. But I cant seem to find the Visio for Enterprise Architects component/tool in...
6
by: spibou | last post by:
In page 81 of N1124 in footnote 87 we read: If the value of the expression is represented with greater precision or range than required by the type named by the cast (6.3.1.8), then the cast...
1
by: templesystems | last post by:
Urgent opening: 1+ yr contracts, Minneapolis, MN .Net Technical Architects (C#, VS, VB, SQL). Must be Architects, not designers or developers. Multiple openings Submit your resumes along with...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.