Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
microsoft.public.dotnet.framework.sdk
xsd and InvalidCastException
(Uma Shinde)
10/8/2002 7:35:00 PM
I used the xsd tool to generate the schema for this xml -
<?xml version="1.0" encoding="utf-8"?>
<HeadlineOut xmlns:xsd="
http://www.w3.org/2001/XMLSc...
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance...
<headlines>
<id>firstID</id>
<headline>first headline</headline>
</headlines>
<headlines>
<id>firstID</id>
<headline>first headline</headline>
</headlines>
</HeadlineOut>
When I use the same schema in my wsdl ( with some modifications as
wsdl throws an error otherwise)
<xs:schema id="HeadlineOut" xmlns=""
xmlns:xs="
http://www.w3.org/2001/XMLSc...
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="HeadlineOut" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="headlines" type="headlineStruct">
</xs:element>
</xs:choice>
</xs:complexType>
<xs:complexType name="headlineStruct">
<xs:sequence>
<xs:element name="id" type="xs:string" minOccurs="0" />
<xs:element name="headline" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I get this error when a similar XML is being returned from my web
service.
Unhandled Exception: System.InvalidOperationException: There is an
error in XML document (2, 885). ---> System.InvalidCastException:
Cannot assign object of type System.Xml.XmlNode[] to an object of type
headline.headlineStruct[].
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read1_HeadlineOut()
at System.Xml.Serialization.XmlSerializationReader.ReadReferencingElement(String
name, String ns, Boolean elementCanBeType, String& fixupReference)
at System.Xml.Serialization.XmlSerializationReader.ReadReferencingElement(String
name, String ns, String& fixupReference)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read6_newportalheadlineResponse()
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
xmlReader)
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
at headline.Headline.newportalheadline() in c:\documents and
settings\ushind01\my documents\visual studio
projects\headline\headline\headline.cs:line 38
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
xsd and InvalidCastException
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password