specify attribute with element data too

A

arcofdescent

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
 
J

Josh Twist

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top