c# - Make webservice client compatible to newer servers -


we have .net client uses proxy class (derived system.web.services.protocols.soaphttpclientprotocol) generated wsdl file wsdl.exe.

up have compatibility between client , webservice webservice changes. old client (with old proxy generated old wsdl file) not call new webservice methods.
problem extension of enum type (xsd.enumeration). special enum used in many get... calls.

example

wsdl

  <xsd:simpletype name="colors">     <xsd:restriction base="xsd:string">       <xsd:enumeration value="red"/>       <xsd:enumeration value="blue"/>       <xsd:enumeration value="unspecified"/>     </xsd:restriction>   </xsd:simpletype> 

proxy code generated wsdl

[system.codedom.compiler.generatedcodeattribute("wsdl", "2.0.50727.3038")] [system.serializableattribute()] [system.xml.serialization.xmltypeattribute(namespace="urn:archive.admin.services.ecm.opentext.com")] public enum colors { red, blue, unspecified } 

error

client knows enum colors values red, blue , unspecified. if server returns new enum value yellow error:

instance validation error: 'yellow' not valid value colors. exception class: system.invalidoperationexception stacktrace:    @ microsoft.xml.serialization.generatedassembly.xmlserializationreaderarchiveadministrationservice.read2_keys(string s)    @ microsoft.xml.serialization.generatedassembly.xmlserializationreaderarchiveadministrationservice.read6_resultfield(boolean isnullable, boolean checktype)    @ microsoft.xml.serialization.generatedassembly.xmlserializationreaderarchiveadministrationservice.read7_resultrecord(boolean isnullable, boolean checktype)    @ microsoft.xml.serialization.generatedassembly.xmlserializationreaderarchiveadministrationservice.read10_invokecommandresponse()    @ microsoft.xml.serialization.generatedassembly.arrayofobjectserializer.deserialize(xmlserializationreader reader)    @ system.xml.serialization.xmlserializer.deserialize(xmlreader xmlreader, string encodingstyle, xmldeserializationevents events) there error in xml document (1, 1557). exception class: system.invalidoperationexception stacktrace:    @ system.xml.serialization.xmlserializer.deserialize(xmlreader xmlreader, string encodingstyle, xmldeserializationevents events)    @ system.xml.serialization.xmlserializer.deserialize(xmlreader xmlreader, string encodingstyle)    @ system.web.services.protocols.soaphttpclientprotocol.readresponse(soapclientmessage message, webresponse response, stream responsestream, boolean asynccall)    @ system.web.services.protocols.soaphttpclientprotocol.invoke(string methodname, object[] parameters) 

this error correct because enumeration. looking pragmatic way avoid exception. see in stacktrace exception thrown code deserializes response xml data proxy's c# enum. our own code can ignore unknown enum value yellow. .net deserialization doesn't know our needs.

i have found soapextensions. need parse whole xml content of every webservice response.

do have idea/solution/workaround avoid above exception? please don't warn me "this bad", "wsdl contract" , on. want pragmatic solution. :-)

i did soapextension. took traceextension sample , modified every response xml checked unknown enum literals. if 1 found extension replaces in xml unused enum literal (unspecified).
client code ignores literal unspecified then.

but 1 problem left: webmethod needs soapextensionattribute (sub class). proxy class webmethod generated code (from *.wsdl). so need set attribute every time code generated. other option configuration imo not possible because have mmc snap-in, *.dll.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -