Handling return values from Java web service
-
Hi all I'm calling a non-.net web service and getting myself confused. The object that is being created from the WSDL includes and out_msg, which is basically the return value. Within out_msg, there is an array of deal objects, however it's not a true array as I can't enumerate it - how do I convert this return value in to something useful (XML, generic list, well, anything really!). /// [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.42")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class out_msg { private object itemField; /// [System.Xml.Serialization.XmlElementAttribute("deals", typeof(deal[]))] [System.Xml.Serialization.XmlElementAttribute("errors", typeof(out_msgErrors))] public object Item { get { return this.itemField; } set { this.itemField = value; } } } Thanks Ben
-
Hi all I'm calling a non-.net web service and getting myself confused. The object that is being created from the WSDL includes and out_msg, which is basically the return value. Within out_msg, there is an array of deal objects, however it's not a true array as I can't enumerate it - how do I convert this return value in to something useful (XML, generic list, well, anything really!). /// [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.42")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class out_msg { private object itemField; /// [System.Xml.Serialization.XmlElementAttribute("deals", typeof(deal[]))] [System.Xml.Serialization.XmlElementAttribute("errors", typeof(out_msgErrors))] public object Item { get { return this.itemField; } set { this.itemField = value; } } } Thanks Ben
Look in the debugger the type, and cast it...
xacc.ide
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach." -
Hi all I'm calling a non-.net web service and getting myself confused. The object that is being created from the WSDL includes and out_msg, which is basically the return value. Within out_msg, there is an array of deal objects, however it's not a true array as I can't enumerate it - how do I convert this return value in to something useful (XML, generic list, well, anything really!). /// [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.42")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class out_msg { private object itemField; /// [System.Xml.Serialization.XmlElementAttribute("deals", typeof(deal[]))] [System.Xml.Serialization.XmlElementAttribute("errors", typeof(out_msgErrors))] public object Item { get { return this.itemField; } set { this.itemField = value; } } } Thanks Ben
You can tweak and change the xsd file to suit your needs. The xml serializer is very leniant. Just do your best to make it match the input schema.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway -
Look in the debugger the type, and cast it...
xacc.ide
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."Thanks Leppie - think I was having a Friday brain melt-down. Had already tried casting to an ArrayList and a generic list of deals objects. But, of course, it was just a good old fashioned array. Cheers Ben
-
You can tweak and change the xsd file to suit your needs. The xml serializer is very leniant. Just do your best to make it match the input schema.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest HemingwayEnnis Ray Lynch, Jr. wrote:
The xml serializer is very leniant.
But not forgiving! Ever had to debug that lame generic XML serialization exceptions? You have to drill down into about 45 inner exceptions to get to the root of the cause :)
xacc.ide
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach." -
Thanks Leppie - think I was having a Friday brain melt-down. Had already tried casting to an ArrayList and a generic list of deals objects. But, of course, it was just a good old fashioned array. Cheers Ben
Bjohnson33 wrote:
Friday brain melt-down
Thats ok :) Happens to everyone ;P
xacc.ide
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."