How To control how WSDL generate schema for nested .NET classes ?

E

enrico sabbadin

Hi,
is there any attrubute I can place on the web service side to control how
nested types are defined in the WSDL ?
basically I'd like that such a definition

public class a1 {
public string x;
public a2 y;
public class a2 {}
}

is not turned into this on the client side (Add web reference in VS.NET),
where class a2 is no more inside class a1.

public class a1 {
public string x;
public a2 y;
}
public class a2 {}

---------
From the WSDLpoint of view the problem is that WSDL spits out this

<s:complexType name="a1">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="x" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="y" type="s0:a2" />
</s:sequence>
</s:complexType>
<s:complexType name="a2" />

instead of embedding a2 into the a1 definition

thank you for your help
--
(e-mail address removed)
MTS - COM+ - VBCOM - Enterprise Services - Security FAQ
..NET & COM+ books selected list
http://www.sabbasoft.com
"Moving fast is not the same as going somewhere."
 
J

Jan Tielens

Are you trying to accomplish what following article describes?
http://tinyurl.com/24qdv
Splitting up WSDL: The Importance of targetNamespace
Scott Seely
Microsoft Corporation

August 20, 2002

Summary: Explores how to use Microsoft Visual Studio .NET to split up the
WSDL into component pieces based on the XML namespace. This allows for reuse
of the XML Schema definitions and WSDL elements. (13 printed pages)
 
E

enrico sabbadin

that's a nice article, but I don't think it addresses my specific issue

thank you anyway
 
C

Chris Rolon

Try the following:

[XmlRoot(Namespace="myServices")]
public class a1 {
public string x;
public a2 y;

[XmlType(Namespace="myServices")]
public class a2 {
}
}


Chris Rolon
 
E

enrico sabbadin @ infinito

Hi Chris,
thank you for your answer,
unfortunately it works partially :
the type is nested in the WSDL, but a2 is put outside a1 on the client side
proxy generated code ..

other suggestions ?


Chris Rolon said:
Try the following:

[XmlRoot(Namespace="myServices")]
public class a1 {
public string x;
public a2 y;

[XmlType(Namespace="myServices")]
public class a2 {
}
}


Chris Rolon

enrico sabbadin said:
Hi,
is there any attrubute I can place on the web service side to control how
nested types are defined in the WSDL ?
basically I'd like that such a definition

public class a1 {
public string x;
public a2 y;
public class a2 {}
}

is not turned into this on the client side (Add web reference in VS.NET),
where class a2 is no more inside class a1.

public class a1 {
public string x;
public a2 y;
}
public class a2 {}

---------
From the WSDLpoint of view the problem is that WSDL spits out this

<s:complexType name="a1">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="x" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="y" type="s0:a2" />
</s:sequence>
</s:complexType>
<s:complexType name="a2" />

instead of embedding a2 into the a1 definition

thank you for your help
--
(e-mail address removed)
MTS - COM+ - VBCOM - Enterprise Services - Security FAQ
.NET & COM+ books selected list
http://www.sabbasoft.com
"Moving fast is not the same as going somewhere."
 

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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top