Changing request encoding

Discussion in 'ASP .Net Web Services' started by Philip Crooks, Jul 11, 2003.

  1. Does anyone know how to change the encoding attribute in the xml
    declaration of a webmethod request?

    I have an ASP.NET client web application which makes calls into an
    ASP.NET web service. The calls are made through client-side proxy
    code, autogenerated by Visual Studio.NET via a web reference. I'm
    using the Web Service Enhancements 1.0 so my client-side proxy class
    inherits from:
    Microsoft.Web.Services.WebServicesClientProtocol
    rather than:
    System.Web.Services.Protocols.SoapHttpClientProtocol
    The client passes a dataset to the web service, where the dataset may
    contain some characters that aren't included in the utf-8 range.
    Currently, when the dataset arrives on the web service these
    characters have been turned into "???". I've been trying to switch to
    unicode encoding to cope with this. I've set the globalization
    attributes in my web.config for the web service:
    <globalization requestEncoding="utf-16"
    responseEncoding="utf-16"/>
    Also, in the client code, I explicitly set the request encoding on the
    web service proxy object:
    wsProxy.RequestEncoding = System.Text.Encoding.Unicode;
    When the client attempts a webmethod call I get an error from the web
    service:

    System.Web.Services.Protocols.SoapException: Server was unable to
    read request. ---> System.Xml.XmlException: There is invalid data at
    the root level. Line 1, position 1.

    When I check the request using the MsSoapT trace utility (from
    Microsoft's SOAP Toolkit) it shows the client request's xml
    declaration with encoding "utf-8":
    <?xml version="1.0" encoding="utf-8" ?>
    I expected this encoding to be "utf-16" and I'm guessing that this is
    something to do with the error.

    Does anyone have any ideas how I can change the encoding in the xml
    declaration?

    Thanks in advance,

    Philip
    Philip Crooks, Jul 11, 2003
    #1
    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. Brian Birtle
    Replies:
    2
    Views:
    1,996
    John Saunders
    Oct 16, 2003
  2. Hardy Wang

    Encoding.Default and Encoding.UTF8

    Hardy Wang, Jun 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    18,804
    Jon Skeet [C# MVP]
    Jun 9, 2004
  3. Replies:
    1
    Views:
    23,320
    Real Gagnon
    Oct 8, 2004
  4. jetcar

    Changing request encoding

    jetcar, Sep 3, 2009, in forum: .NET
    Replies:
    0
    Views:
    625
    jetcar
    Sep 3, 2009
  5. Replies:
    2
    Views:
    355
Loading...

Share This Page