Introduce DataBase,Asp.net,JavaScript,Xml,Html,Css,Sql,Php,ASP.NET Controls,AJAX,Tools,HTML,CSS,JavaScript,Open Source Project,WPF,.Net Framework,Linq
Top Recommended Hosting

Web Services and XML Serialization C# client with SOAP::Lite webservice, results are always null

by the3factory 4/9/2008 5:18:00 PM
Web Services and XML Serialization C# client with SOAP::Lite webservice, results are always null
Question:
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 = "urnBig Smileemo")]
    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 xmlnsTongue Tiedoap="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" xmlnsTongue Tiedoapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlnsTongue Tiedoap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><c2fResponse xmlns="Demo"><namesp1:c2fresult xmlns:namesp1="Demo" xsi:type="xsdTongue Tiedtring">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?

Answer1:
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. 

Related posts

Sign up for PayPal and start accepting credit card payments instantly.


Powered by BlogEngine.NET 1.2.0.0