WebService proxy class naming

Discussion in 'ASP .Net Web Services' started by Paul, Aug 1, 2006.

  1. Paul

    Paul Guest

    I have simple web method like the following:

    [WebMethod(Description = "Gets an instance of the Person class.",
    MessageName = "Person")]
    public Person GetPerson()
    {
    return CreatePerson();
    }

    When I compile the web service, it generates the following WSDL snippet:


    <s:element name="PersonResponse">
    <s:complexType>
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" ref="s1:personResult" />
    </s:sequence>
    </s:complexType>
    </s:element>

    On the WS consumer side, WDSL.EXE generates a "PersonResult" instead of a
    "Person" class. Is there a way to decorate my WS code so the class generated
    is named "Person"?


    Paul
    Paul, Aug 1, 2006
    #1
    1. Advertising

  2. Paul

    Paul Wu Guest

    In your web service's xml attribute decoration, make sure you provide the root element name to be used by the XmlSerializer. For example:

    [System.Xml.Serialization.XmlRootAttribute(Namespace="http://namespace", ElementName="Person")]
    public class Person {}


    -------------------------------------
    Paul Wu





    >I have simple web method like the following:
    >
    > [WebMethod(Description = "Gets an instance of the Person class.",
    > MessageName = "Person")]
    > public Person GetPerson()
    > {
    > return CreatePerson();
    > }
    >
    > When I compile the web service, it generates the following WSDL snippet:
    >
    >
    > <s:element name="PersonResponse">
    > <s:complexType>
    > <s:sequence>
    > <s:element minOccurs="0" maxOccurs="1" ref="s1:personResult" />
    > </s:sequence>
    > </s:complexType>
    > </s:element>
    >
    > On the WS consumer side, WDSL.EXE generates a "PersonResult" instead of a
    > "Person" class. Is there a way to decorate my WS code so the class generated
    > is named "Person"?
    >
    >
    > Paul
    >
    >
    Paul Wu, Aug 1, 2006
    #2
    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. Harman
    Replies:
    1
    Views:
    2,489
    Moiristo
    Jul 28, 2006
  2. Madjid Nasiri

    Call a webservice with out using proxy class

    Madjid Nasiri, Oct 26, 2004, in forum: ASP .Net Web Services
    Replies:
    5
    Views:
    280
    Madjid Nasiri
    Nov 21, 2004
  3. Replies:
    2
    Views:
    720
  4. Joydeep
    Replies:
    1
    Views:
    156
  5. walter

    Change TargetNameSpace in webservice proxy class

    walter, Feb 14, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    283
    walter
    Feb 14, 2006
Loading...

Share This Page