Professional Web Applications Themes
  1. #1

    Default XmlSerializer in SOAP message

    Hi All,

    I would like to get rid of the following attributes when I
    serialize a class into an XML
    xmlns:xsd=http://www.w3.org/2001/XMLSchema
    xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance

    This is not a problem when you are in charge of creating
    an XmlSerializer object. All you need to do is to add an
    empty XmlSerializerNamespaces collection. Something like
    this:

    TestClass obj;
    XmlWriter writer;
    XmlSerializer xs = new XmlSerializer( typeof( TestClass ));
    XmlSerializerNamespaces namespaces =
    new XmlSerializerNamespaces();
    namespaces.Add( "", "" );
    xs.Serialize( writer, obj, namespaces );


    However, when you implement a Web Service method, you
    don't have access to XmlSerializer object.

    I am wondering how I can suppress the xmlns:xsd and
    xmlns:xsi xml namespaces serialization in this case?

    Thank you,
    Dima Maltsev

    Dima Maltsev Guest

  2. #2

    Default RE: XmlSerializer in SOAP message

    Hi Dima,

    To control the XML generated by an XML Web service, we can apply the
    attributes (Which control XML Serialization and Which control Encoded SOAP
    Serialization) to the classes, return values, parameters, and fields of a
    file used to create an XML Web service (.asmx). For specify a namespace,
    you may take a look at XmlRootAttribute Class:

    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/[/url]
    frlrfSystemXmlSerializationXmlRootAttributeClassTo pic.asp

    Hope this help,

    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    MSFT Guest

  3. #3

    Default RE: XmlSerializer in SOAP message

    Hi Luke,

    Thank you for the reply.
    I am aware of XML Serialization attributes and I tried to
    use almost all of them. In particular, with
    XmlRootAttribute you can control the value for your own
    namespace (e.g. xmlns=www.dimamaltsev.com). However, no
    matter what you do with attributes it seems you cannot get
    rid of the following default namespaces:

    xmlns:xsd=http://www.w3.org/2001/XMLSchema
    xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance

    As I mentioned the only way I know how to remove them is
    to construct the XmlSerializer object and "tell" it not to
    use namespaces. Unfortunately, in case of Web Service
    implementation you do not create XmlSerializer (.NET
    framework does).

    Back to my question:
    Is there any away to get rid of
    xmlns:xsd=http://www.w3.org/2001/XMLSchema
    xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
    attributes in Web Service response?

    Happy Holidays to Everyone!
    Dima Maltsev
    >-----Original Message-----
    >Hi Dima,
    >
    >To control the XML generated by an XML Web service, we
    can apply the
    >attributes (Which control XML Serialization and Which
    control Encoded SOAP
    >Serialization) to the classes, return values, parameters,
    and fields of a
    >file used to create an XML Web service (.asmx). For
    specify a namespace,
    >you may take a look at XmlRootAttribute Class:
    >
    >[url]http://msdn.microsoft.com/library/default.asp?[/url]
    url=/library/en-us/cpref/html/
    >frlrfSystemXmlSerializationXmlRootAttributeClassT opic.asp
    >
    >Hope this help,
    >
    >Luke
    >Microsoft Online Support
    >
    >Get Secure! [url]www.microsoft.com/security[/url]
    >(This posting is provided "AS IS", with no warranties,
    and confers no
    >rights.)
    >
    >.
    >
    Dima Maltsev Guest

  4. #4

    Default RE: XmlSerializer in SOAP message

    In .NET web service, the serializer is controled by the ASP.NET
    infrastructure, we cannot access the its XMLSerializer object. A work
    around is to modify the SOAP message with SOAP extension before it is sent
    to client. For more detial, you may refer to following article:

    Altering the SOAP Message Using SOAP Extensions
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm[/url]
    l/cpconAlteringSOAPMessageUsingSOAPExtensions.asp


    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    MSFT Guest

Similar Threads

  1. SOAP Message
    By gporto in forum Macromedia Flex General Discussion
    Replies: 1
    Last Post: October 22nd, 11:39 AM
  2. Building a Soap Message
    By Christopher D. Wiederspan in forum ASP.NET Web Services
    Replies: 5
    Last Post: December 10th, 06:08 PM
  3. SOAP Message from WSE
    By Patrick in forum ASP.NET Web Services
    Replies: 14
    Last Post: October 5th, 05:56 AM
  4. Get raw soap message
    By Jason Zhou in forum ASP.NET Web Services
    Replies: 5
    Last Post: August 24th, 10:45 PM
  5. ASCII 0-31 in soap message
    By Mike deBruin in forum ASP.NET Web Services
    Replies: 0
    Last Post: November 17th, 06:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139