|
Hi,
I have a complex element in my XSD which looks like
< xs:element name="Products">
< xs:complexType>
< xs:sequence>
< xs:element ref="pd:Prod" maxOccurs="6"/>
</ xs:sequence>
</ xs:complexType>
</ xs:element>
And this complex element is used as a child element as shown below:
< xs:element name="ProductCatalog">
< xs:complexType>
< xs:sequence>
< xs:element ref="pd:ProdId"/>
< xs:element ref="pd:Products" minOccurs="0" maxOccurs="2"/>
</ xs:sequence>
</ xs:complexType>
</ xs:element>
I create the WSDL and the server side code using WSCF. When I try to consume this webservice, I'm getting an error in the Reference.vb file.
Error is: Unable to generate a temporary class (result=1). error CS0029: Cannot implicitly convert type 'TestCatalog.Catalog.ProdType' to 'TestCatalog.Catalog.ProdType[]'
The code snippet in Reference.vb where this error occurs is:
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.1433"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://www.w3cschools.com/Products")> _
Partial Public Class ProductCatalogType
Private ProdIdField As String
Private ProductsField()() As ProdType
And the property for this field is:
<System.Xml.Serialization.XmlArrayItemAttribute("Prod", GetType(ProdType), IsNullable:=false)> _
Public Property Products() As ProdType()()
Get
Return Me.ProductsField
End Get
Set(ByVal value As ProdType()())
Me.ProductsField = value
End Set
End Property
When I make a couple of changes in my Reference.vb file manually, i'm able to consume the webservice without any error.
The changes that i made are:
1. Changing Private ProductsField()() As ProdType to Private ProductsField() As ProdType
2. Changing the property as:
<System.Xml.Serialization.XmlArrayItemAttribute("Prod", GetType(ProdType), IsNullable:=false)> _
Public Property Products() As ProdType()
Get
Return Me.ProductsField
End Get
Set(ByVal value As ProdType())
Me.ProductsField = value
End Set
End Property
If someone can tell me why this error occured, it would be of great help. Also let me know if I have to make modifications in my XSD so that I don't have to manually edit Reference.vb
|