locked
Proxy class from WSDL reusing known types. RRS feed

  • Question

  • Hi,

    Is there a way to generate a proxy class from WSDL by reusing classes from shared assembly?

    I have reference to shared assembly which has few classes which WSDL has and i don't want WSDL tool to generate classes for those.

    Thanks
    Monday, November 16, 2009 9:20 PM

Answers

  • I found the solution. I commented out all the shared types from proxy class (generated by wsdl) and added [XmlInclude] attribute on proxy class for all types in shared assembly. I am not sure its the right approach.
    • Marked as answer by Ji.Zhou Thursday, November 26, 2009 4:09 AM
    Monday, November 16, 2009 11:59 PM
  • Hello Santosh,

    Yes, [XMLInclude] attribute tells a XMLSerializer to recognize a type when it serializes or deserializes an object. That should be the right solution.

    Some points I want to add,
    1. When following this way, the programmer must access the shared assembly's source codes. That is a disadvantage.
    2. If we do this, we are responsible to make sure classes in your shared assembly are 100% compatiable with the classes generated by wsdl. Otherwise, you may encounter exceptions when doing serialization or deserialization.
    3. Every time our webserivce types change, we have to manually adjust the shared assembly.

    Based on these points, unless we really have a good reason to do that, then I think the WSDL generated types are recommendded.

    Have a nice day!

     

     

    Ji Zhou

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Proposed as answer by Ji.Zhou Monday, November 23, 2009 4:13 AM
    • Marked as answer by Ji.Zhou Thursday, November 26, 2009 4:09 AM
    Monday, November 23, 2009 4:11 AM

All replies

  • Unless I am misunderstanding you, the short answer is no.

    I had a similar situation where a WSDL would generate a new namespace for a common shared assembly. I had to hand edit the output to use the common namespace and not create a new object.
    William Wegerson (www.OmegaCoder.Com)
    Monday, November 16, 2009 11:24 PM
  • Even we specify the same namespace as of shared assembly in WSDL command line, it would still create a proxy class with all types generated (including those exist in shared assembly)

    Eg.

    1. Shared Assembly "SA", with namespace "NS"  has a class "A".
    2. SA is available to service and client. And one of the web methods return type is A.
    3. When i create a proxy class with namespace parameter as "NS", wsdl would still create a new class "A" for Proxy class instead of reusing it from SA.

    i would like proxy class to use class A from SA.

    Monday, November 16, 2009 11:51 PM
  • I found the solution. I commented out all the shared types from proxy class (generated by wsdl) and added [XmlInclude] attribute on proxy class for all types in shared assembly. I am not sure its the right approach.
    • Marked as answer by Ji.Zhou Thursday, November 26, 2009 4:09 AM
    Monday, November 16, 2009 11:59 PM
  • Hello Santosh,

    Yes, [XMLInclude] attribute tells a XMLSerializer to recognize a type when it serializes or deserializes an object. That should be the right solution.

    Some points I want to add,
    1. When following this way, the programmer must access the shared assembly's source codes. That is a disadvantage.
    2. If we do this, we are responsible to make sure classes in your shared assembly are 100% compatiable with the classes generated by wsdl. Otherwise, you may encounter exceptions when doing serialization or deserialization.
    3. Every time our webserivce types change, we have to manually adjust the shared assembly.

    Based on these points, unless we really have a good reason to do that, then I think the WSDL generated types are recommendded.

    Have a nice day!

     

     

    Ji Zhou

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Proposed as answer by Ji.Zhou Monday, November 23, 2009 4:13 AM
    • Marked as answer by Ji.Zhou Thursday, November 26, 2009 4:09 AM
    Monday, November 23, 2009 4:11 AM