I'm trying to get a simple example working with a C# client and a SOAP::Lite webservice. The service works if I use a SOAP::Lite client with it, and if I watch the trace with the C# client I can see a valid result being returned, but the result in my C# code is always null. Here is the relevant code and trace output:C# client code: [System.Web.Services.WebServiceBindingAttribute(Name = "DemoProxy", Namespace = "urnemo")] public class DemoProxy : System.Web.Services.Protocols.SoapHttpClientProtocol { public DemoProxy() { this.Url = "https://myurl.com/soap.pl"; ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate; } [System.Web.Services.Protocols.SoapDocumentMethodAttribute("Demo#c2f", RequestNamespace = "Demo", ResponseNamespace = "Demo", ResponseElementName = "c2fresult")] public string c2f(decimal degree) { object[] results = this.Invoke("c2f", new object[] { degree }); return ((string)results[0]); } }Send trace:<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlnsoap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><c2f xmlns="Demo"><degree>32</degree></c2f></soap:Body></soap:Envelope>Response from service:<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlnsoapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlnsoap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><c2fResponse xmlns="Demo"><namesp1:c2fresult xmlns:namesp1="Demo" xsi:type="xsdtring">89.6</namesp1:c2fresult></c2fResponse></soap:Body></soap:Envelope>I have tried fiddling with the namespaces and the types and even switched to a string return from a decimal but the result is always the same: results only has a count of 1 and the value is null. Anyone have any pointers as to what I'm doing wrong or what I'd need to change?
I would guess this was a namespace issue. Having generated a WSDL file for the service (using POD::WSDL for those who care) and generating the proxy class from that file made it work flawlessly.
Tags: web services and xml serialization
Q&A
Powered by BlogEngine.NET 1.2.0.0
© Copyright 2009