specify attribute with element data too

Discussion in 'ASP .Net Web Services' started by arcofdescent@gmail.com, Feb 20, 2006.

  1. Guest

    Hi,

    I'm been trying like crazy but I'm not able to specify the correct WSDL
    type definitions for the following:

    i.e. the SOAP request XML is:

    <status code="100">All Fine</status>

    How do we write the WSDL definition for this XML?

    I started by defining the status type.

    So,

    <xsd:element name="status" type="typens:statusType"/>

    Then, i define the statusType to have an attribute

    <xsd:complexType name="statusType">
    <xsd:attribute name="code" type="xsd:string"/>
    </xsd:complexType>

    But I'm stuck at how to specify that the status element also would need
    to have a string data.

    Thanks,
    Rohan
    , Feb 20, 2006
    #1
    1. Advertising

  2. Josh Twist Guest

    Hi Rohan,

    In c# the type might look like this:

    [XmlRoot("status")]
    public class Status
    {
    [XmlAttribute("code")]
    public int Code;

    [XmlText]
    public string Value;
    }

    Which wsdl.exe turns into

    <s:complexType name="Status">
    <s:simpleContent>
    <s:extension base="s:string">
    <s:attribute name="code" type="s:int" use="required" />
    </s:extension>
    </s:simpleContent>
    </s:complexType>

    Josh
    http://www.thejoyofcode.com/
    Josh Twist, Feb 21, 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. anonymous
    Replies:
    1
    Views:
    5,940
  2. =?Utf-8?B?TWFyaw==?=
    Replies:
    4
    Views:
    629
    =?Utf-8?B?TWFyaw==?=
    Dec 14, 2006
  3. perspolis
    Replies:
    1
    Views:
    2,556
    Mark Rae
    Jan 23, 2007
  4. Joe Kovac
    Replies:
    2
    Views:
    946
    Joe Kovac
    May 2, 2007
  5. James
    Replies:
    2
    Views:
    965
    Joe Kesselman
    Jul 28, 2007
Loading...

Share This Page