c# - WSDL.exe generated client gives: Unhandled Exception: System.InvalidOperationException: There is an error in XML document (...) -


i have webservice returns complex objects.

public class resource;     public class asset extends resource; public class collection extends resource; 

the methods return subclasses work fine:

asset[] getassets(); collection[] getcollections(); 

however methods return base class generating exception:

resource[] getresources(); 

the webservice written in java using cxf dont think matters. able use base class methods sample client created java.

here exception using .net client:

`unhandled exception: system.invalidoperationexception: there error in xml document (1, 173). ---> system.invalidoperationexception: specified type not recognized: name='asset', namespace='http://www.turimsaint.com/', @ <return xmlns=''>`. 

here client code generated wsdl.exe

[system.web.services.protocols.soapdocumentmethodattribute("", requestnamespace = "http://www.turimsaint.com/", responsenamespace = "http://www.turimsaint.com/", use = system.web.services.description.soapbindinguse.literal, parameterstyle = system.web.services.protocols.soapparameterstyle.wrapped)] [return: system.xml.serialization.xmlelementattribute("return", form = system.xml.schema.xmlschemaform.unqualified)] public resource[] getcollectioncontents([system.xml.serialization.xmlelementattribute(form = system.xml.schema.xmlschemaform.unqualified)] collection p_collection) {     object[] results = this.invoke("getcollectioncontents", new object[] {             p_collection});     return ((resource[])(results[0])); } 

and lastly wsdl related elements:

- <xs:complextype name="collection"> - <xs:complexcontent> - <xs:extension base="tns:resource"> - <xs:sequence>   <xs:element name="_instructor" type="xs:string" />    </xs:sequence>   </xs:extension>   </xs:complexcontent>   </xs:complextype> - <xs:complextype abstract="true" name="resource"> - <xs:sequence>   <xs:element name="_title" type="xs:string" />    <xs:element name="_deeplink" type="xs:string" />    <xs:element name="_id" type="xs:string" />    <xs:element name="_description" type="xs:string" />    <xs:element name="_type" type="xs:string" />    <xs:element maxoccurs="unbounded" name="_metadata" type="tns:resourcemetadata" />    </xs:sequence>   </xs:complextype>  ....  - <xs:complextype name="getresourcebyidresponse"> - <xs:sequence>   <xs:element minoccurs="0" name="return" type="tns:resource" />    </xs:sequence>   </xs:complextype> 

any appreciated. thanks.

this digging little, been while since playing .net 2.0 style web service clients.

if remember correctly, you´ll have attribute work. you´ll have inform base class ´resource´ possibly derived classes ´asset´-´collection´ or methods returning 1 of derived classes placing attributes on top.

have at

http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlincludeattribute.aspx

hope helps,


Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -