473,698 Members | 2,932 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 1229

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

Similar topics

3
1956
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
2350
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
2274
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
2338
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
1426
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
8683
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
8611
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
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
9031
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
8904
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
5867
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
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
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.