Serializable object as input parameter to web method

Discussion in 'ASP .Net Web Services' started by deja@2bytes.co.uk, Jul 27, 2006.

  1. Guest

    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
     
    , Jul 27, 2006
    #1
    1. Advertising

  2. Guest

    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

    wrote:
    > 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
     
    , Jul 28, 2006
    #2
    1. Advertising

  3. <> wrote in message
    news:...
    >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
     
    John Saunders, Jul 29, 2006
    #3
  4. Guest


    > 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
     
    , Jul 29, 2006
    #4
  5. <> wrote in message
    news:...
    >
    >> 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:))


    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
     
    John Saunders, Jul 29, 2006
    #5
  6. D-Someone Guest

    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?

    "John Saunders" wrote:

    > <> wrote in message
    > news:...
    > >
    > >> 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:))

    >
    > 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-Someone, Aug 2, 2006
    #6
  7. "D-Someone" <> wrote in message
    news:...
    >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
     
    John Saunders, Aug 3, 2006
    #7
  8. Guest

    > 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.


    Michael Feingold wrote:
    > I have the same problem - what good is this IXMlSerializable if only one part
    > of it gets used? Anyway the only workaround I found is to manually edit the
    > 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
    >
    > "" wrote:
    >
    > > 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
    > >
    > > wrote:
    > > > 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

    > >
    > >
     
    , Sep 2, 2006
    #8
  9. 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

    "" wrote:

    > > 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.
    >
    >
    > Michael Feingold wrote:
    > > I have the same problem - what good is this IXMlSerializable if only one part
    > > of it gets used? Anyway the only workaround I found is to manually edit the
    > > 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
    > >
    > > "" wrote:
    > >
    > > > 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
    > > >
    > > > wrote:
    > > > > 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
    > > >
    > > >

    >
    >
     
    Michael Feingold, Sep 3, 2006
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Line
    Replies:
    8
    Views:
    665
    Tony Morris
    Jan 14, 2004
  2. Christian Schuhegger
    Replies:
    4
    Views:
    794
    Christian Schuhegger
    Aug 11, 2004
  3. Jimmy
    Replies:
    4
    Views:
    646
    Thomas Hawtin
    Aug 8, 2007
  4. Replies:
    8
    Views:
    3,022
  5. Miquel
    Replies:
    1
    Views:
    135
    Miquel
    Sep 13, 2007
Loading...

Share This Page