all groups > asp.net webservices > february 2006 >
You're in the

asp.net webservices

group:

specify attribute with element data too


specify attribute with element data too arcofdescent NO[at]SPAM gmail.com
2/20/2006 12:26:32 PM
asp.net webservices:
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
Re: specify attribute with element data too Josh Twist
2/21/2006 12:02:16 AM
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/
AddThis Social Bookmark Button