Serializable object as input parameter to web method

D

deja

Hi

I have a class library that defines a serializable class. I reference
this library in both my Web App (front-end) and my Web Service.

My web service expects an instance of this class as one of the input
parameters for one of its methods. I thought I could just create an
instance at the front-end Web App, then pass it through to the web
service but instead I have to specifically create an instance of the
"Web Service" version of the class not the original class library
version.

Is there a way I can use just the standard class library object (both
Web App and Web Service reference the object using the full namespace
of the class library) or an easy way of me converting one to the other
or am I missing something blindingly obvious?

tia
Phil
 
D

deja

i understand a web service should not be tightly coupled by using the
same object
and I have seen solutions in editing the .cs file generated when adding
a web reference for v1.1 by deleting the proxy class and referencing
the original class BUT as far as I can tell there is no .cs file in
v2.0 - and it is not clear to me how to edit the wsdl file.

I am using a class library that I cannot change (by adding the
XMLType(Namespace) attribute - so how do I accomplish this if I want to
go down the route of tight coupling?

thanks
 
J

John Saunders

i understand a web service should not be tightly coupled by using the
same object
and I have seen solutions in editing the .cs file generated when adding
a web reference for v1.1 by deleting the proxy class and referencing
the original class BUT as far as I can tell there is no .cs file in
v2.0 - and it is not clear to me how to edit the wsdl file.

I am using a class library that I cannot change (by adding the
XMLType(Namespace) attribute - so how do I accomplish this if I want to
go down the route of tight coupling?

thanks

If you want tight coupling, then you don't want Web Services, you want .NET
Remoting.

John
 
D

deja

If you want tight coupling, then you don't want Web Services, you want .NET
Remoting.

John

er, but if I wanted that I wouldn't have asked this question. And I
know it is possible but I don't know how to implement it. I want the
tight coupling but with the independence of Web Services and the
avoidance of firewall issues etc.

So, does anyone know how to implement it - is it
schemaImporterExtensions or do I need to change the proxy class (but I
can't find the proxy class in .NET 2) or what?

thanks (but don't tell me what I want :eek:))

Phil
 
J

John Saunders

er, but if I wanted that I wouldn't have asked this question. And I
know it is possible but I don't know how to implement it. I want the
tight coupling but with the independence of Web Services and the
avoidance of firewall issues etc.

So, does anyone know how to implement it - is it
schemaImporterExtensions or do I need to change the proxy class (but I
can't find the proxy class in .NET 2) or what?

thanks (but don't tell me what I want :eek:))

Did you know that .NET Remoting can communicate using SOAP over HTTP? That
would give you the tight coupling and the avoidance of Firewall issues.

I don't see how you could conceivably acheive tight coupling and
independance at the same time.

John
 
D

D-Someone

I don't think he needs tight coupling. I am very interested in an answer
here as well. It seems to me he has a serializable class that both the
client and web service are referencing. Now if your class is serializable
what is the problem with passing that as a web service parameter from the
client? I would think that should work out of the box. The client knows
what parameters the server web method is looking for (the XML schema).. the
serialized class serializes itself into that same XML schema when it is
passed to the web method from the client.

What is he doing wrong here? How can this be done... again I don't see it
as tight coupling. Even in a loosely coupled scenario the client needs to
know what the server wants passed in....and he is attempting to do this with
no avail.

Is this what you are looking for a solution for or am I way off base here??
Have you found a web service solution already?

Can anyone help?
 
J

John Saunders

D-Someone said:
I don't think he needs tight coupling. I am very interested in an answer
here as well. It seems to me he has a serializable class that both the
client and web service are referencing. Now if your class is serializable
what is the problem with passing that as a web service parameter from the
client? I would think that should work out of the box. The client knows
what parameters the server web method is looking for (the XML schema)..
the
serialized class serializes itself into that same XML schema when it is
passed to the web method from the client.

What is he doing wrong here? How can this be done... again I don't see it
as tight coupling. Even in a loosely coupled scenario the client needs to
know what the server wants passed in....and he is attempting to do this
with
no avail.

"Serializable" does not imply "XML Serializable". Also, depending on
serialization puts control of your schema in the hands of .NET, It should be
in your control. Create your own schemas and WSDL (do not depend on the
schemas and WSDL which ASP.NET generates for you).


John
 
D

deja

proxy .NET framework generates from wsdl. Yes you are right such a file does
exist - it is sitting in webReferences/YourService/Reference.Map directory
and its name is Reference.cs

not in .NET 2 it isn't. That was my point - where is it in .NET 2? But
actually I think there is a solution using schemaImporterExtensions
though I am not fully up to speed with it. Also re tight/loose
coupling: obviously there are purists and pedants who know the full
definition as defined by the founder of XML etc. All I expect by loose
coupling (and it may not be the proper definition) is that any new
client app can call the web service but equally those client apps could
change to call a different service using the same class - they are not
tied in to my web service nor is my web service only good for a
specific client. Using a shared library would achieve this in my
opinion.
 
M

Michael Feingold

Well, I am. Working with VS2005 (and .Net 2.0) that is. And here is a header
of the Reference.cs file this thing generated for me:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

//
// This source code was auto-generated by Microsoft.VSDesigner, Version
2.0.50727.42.
//

Might be this is a matter of some setting somewhere...

Another thing I was trying to puzzle out is that the code generator seems to
ignore the SOAPType (or XMLType) attribute. I tried to apply this attribute
to the class in question with the parameter IncludeInSchema=false. It had no
effect
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top