stallamy

stallamy

  • NA
  • 1
  • 0

Deserializing complex objects

Jan 17 2005 10:56 AM
I'm trying to use C# to connect to a SOAP server but having problems receving complex objects as return values. Here is the code: First is my proxy: [System.Web.Services.WebServiceBindingAttribute(Name="urn:ItemManager",Namespace="urn:Configuration")] public class Configuration: SoapHttpClientProtocol { public Configuration() { this.Url = "http://localhost:7001/soap/servlet/rpcrouter"; } [SoapDocumentMethodAttribute ("",RequestNamespace="urn:Configuration",ResponseNamespace="urn:Configuration",Use= System.Web.Services.Description.SoapBindingUse.Encoded, ParameterStyle=SoapParameterStyle.Wrapped)] public SiteConfig getSiteConfig() { object [] results = this.Invoke("getSiteConfig", new object[] {}); SiteConfig site = (SiteConfig)results[0]; return site; } } My complex object: public class SiteConfig { public int numRouters; public int numSwitches; } Test client: public class Test { public static void Main(string[] args) { Configuration config = new Configuration(); SiteConfig site = config.getSiteConfig(); Console.WriteLine(site.numRouters+""); } } The problem I am getting is I get a "System.NullReferenceException: Object reference not set to an instance of an object." on the line Console.WriteLine(site.numRouters+""); in the Test client. I've been looking at the SOAP messages and they seem to be working find. The response from the server looks like: 10 20 Any help would be great!

Answers (1)