473,811 Members | 3,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Proxy Class generation problem

The “Add Web Reference” Visual tool generates bad classes (from WSDL schema)
for ComplexType containing only one element (wsdl.exe and wseWsdl3.exe tools
have the same problem) : if a ComplexType A contains only one element, the
tool don’t generate a class for the ComplexType A. It generates a class only
for the element type (B) included in this ComplexType (if this type contains
more than one element...). For types in WSDL schéma including a ComplexType A
element, the generated classes for these types contains a B element (and not
a A element containing a B element).

For example, for this part of WSDL schema:

<xsd:complexTyp e name="ClassInst ">
<xsd:sequence >
<xsd:element name="ClassName " type="ClassName "/>
<xsd:element name="Inst" type="Instance" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType >

<xsd:complexTyp e name="Structure dEntitySpec">
<xsd:sequence >
<xsd:element name="EntityCla ssInst" type="ClassInst " maxOccurs="10"/>
</xsd:sequence>
</xsd:complexType >

<xsd:complexTyp e name="EntitySpe c">
<xsd:sequence >
<xsd:element name="Structure d" type="Structure dEntitySpec" minOccurs="0"/>
<xsd:element name="Syno" type="xsd:strin g" minOccurs="0"/>
<xsd:element name="Natural" type="xsd:strin g" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType >

Will generate the following code:

public partial class ClassInst {

private string classNameField;
private Instance instField;
....
}

public partial class EntitySpec {

private ClassInst[] structuredField ;
private string synoField;
private string naturalField;

}

The EntitySpec class doesn’t contain a StructuredEntit ySpec element but a
ClassInst[] element (declared in the StructuredEntit ySpec XML element).

This error cause deserialization problems. when the Web Service client
receive the SOAP message :

....
<entitySpec>
<structured>
<EntityClassIns t>
<ClassName>.. .</ClassName>
<Inst>...<Ins t>
</ EntityClassInst >
</structured>
<syno></syno>
<natural></natural>
</entitySpec>
....

the entitySpec XML element is not conform to classes structure : the
<EntityClassIns t> element is not declared in classes so deserialization
failed (the <EntityClassIns t> is unknown).
Deserializer needs to have this XML element :
....
<entitySpec>
<structured>
<ClassName>.. .</ClassName>
<Inst>...<Ins t>
</structured>
<syno></syno>
<natural></natural>
</entitySpec>
....

To prevent from this bug, in all ComplexType containing only one element, we
had to add a new optional element (unused) :

<xsd:complexTyp e name="ClassInst ">
<xsd:sequence >
<xsd:element name="ClassName " type="ClassName "/>
<xsd:element name="Inst" type="Instance" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType >

<xsd:complexTyp e name="Structure dEntitySpec">
<xsd:sequence >
<xsd:element minOccurs="0" name="WorkAroun ddotNetBug" type="xsd:integ er"/>
<xsd:element name="EntityCla ssInst" type="ClassInst " maxOccurs="10"/>
</xsd:sequence>
</xsd:complexType >

<xsd:complexTyp e name="EntitySpe c">
<xsd:sequence >
<xsd:element name="Structure d" type="Structure dEntitySpec" minOccurs="0"/>
<xsd:element name="Syno" type="xsd:strin g" minOccurs="0"/>
<xsd:element name="Natural" type="xsd:strin g" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType >

Generated classes for these XML types :

public partial class ClassInst {

private string classNameField;
private Instance instField;
....
}

public partial class StructuredEntit ySpec {

private string workArounddotNe tBugField;
private ClassInst[] entityClassInst Field;
....
}

public partial class EntitySpec {

private StructuredEntit ySpec structuredField ;
private string synoField;
private string naturalField;
....
}
Generated classes are now conform to XML document.

_______________ ___________
Benjamin BALET
Capgemini France
http://bbalet.free.fr/
Feb 24 '06 #1
0 1235

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1968
by: Marty McDonald | last post by:
Using Visual Studio.Net... I have two classes, one derives from the other. My web service accepts the base class as input, it returns the derived class as the return value. When I set a web reference to that web service, the web service proxy is incorrect! It creates its own version of the base class fine, but when it creates its own version of the derived class, it shows it as simply deriving from the base, but its own members are not...
3
2355
by: Ohad Young | last post by:
Hi, I have a webservice method that returns an instance of a custom class I created (e.g., bank account). The class definition in the webservice contains properties, overrides Object.ToString method and etc. However, the proxy created for the webservice contains a definition for this class without the code I wrote. Instead it contains only public fields. I understand the reason, interoperability with none .net clients, but is there...
1
2283
by: Sarge | last post by:
Hi all, tough question. Apologies for the cross posting but it is an interesting architectural problem and I think deserves a wide audience. What is the best way to extend web service proxy classes so we can add our own methods and properties? We have an application that passes a deep hierarchical structure (four nodes deep) between a webservice and a smart client. We have built the web service using the Contract First Web Service...
2
2343
by: Julian Jelfs | last post by:
Hi, In Visual Studio 2005 it appears that you don't have access to the proxy class generated by the tool when you add a reference to a web service. This is a problem for me since I have a web service which makes use of WSE 2. As such I need the proxy class to be of type Microsoft.Web.Services2.WebServicesClientProtocol rather the usual base class which means I need to edit the generated class. This was no problem in VS 2003 because I...
1
1429
by: Tyler Carver | last post by:
I have created a web reference in a 2005 web project and need to change out the generated complex class with the business oject that we have already created. In a library project there is a code file for the proxy class where I can make the change. However, there is no such file in a Web Project as this class is generated on the fly. So what I need to do is the following: I have a business object Foo. My Webservice has a method...
0
9730
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10651
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10392
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10403
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10136
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5555
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5693
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3020
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.