Home » c# » c# – dotnet-svcutil-generated WCF proxy (and even a custom Channel<>) are returning null for a valid SOAP response

c# – dotnet-svcutil-generated WCF proxy (and even a custom Channel<>) are returning null for a valid SOAP response

Posted by: admin February 21, 2020 Leave a comment


Proxy generated with dotnet-svcutil 2.0.1 (dotnet-svcutil --sync --outputDir . http://XXX/?WSDL) and System.ServiceModel.* 4.7.0, calling code and ?WSDL below. Proxy simply fails to deserialize the valid response and just returns null. Have tried both .NET Core 3.0 and 3.1 on Windows 10 and macOS Catalina, same null result. Fiddler request and response attached along with ?WSDL from server (server beyond my control).

With the proxy I am using @shmao’s set_mode workaround (https://github.com/dotnet/wcf/issues/2219) to avoid the ‘JScript/CSharp scripts is not supported’ exception. Further, I have to remove the Namespace="" attributes to get even the request part working. I have added EventListeners and dumped everything at Verbose from all event sources, no warnings/errors, just the null.

Have also tried the Channel-based MessageContract/DataContract approach, ultimately same null result (!), I am unable to leverage any .NET Core WCF-based code to deserialize the given response.

Any solution or even partial solution to deserializing given response using .NET Core 3.1 WCF will be considered, ideally with dotnet-svcutil. Uncovering a warning/error or even getting access to the response string manually would still be an improvement over a non-WCF string/HttpRequest-based approach.

      WSWebServiceSoapPortClient proxy;
      try {
        proxy = new WSWebServiceSoapPortClient(new BasicHttpBinding(),
          new EndpointAddress("http://XXX"));

        await proxy.OpenAsync();
      } catch (Exception e) {

      if (proxy.State == System.ServiceModel.CommunicationState.Faulted) {
        System.Console.WriteLine("Unable to connect to the proxy.");

      var one = new WSUserLoginRequest1(new WSUserLoginRequest() {
        userName = "XXX",
        userPassword = "XXX",
      WSUserLoginResponse1 wsUserLoginResponse = null;

      try {
        wsUserLoginResponse = await proxy.WSUserLoginAsync(one);   // returns null
      } catch (Exception e) {

Relevant WSDL from server

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
  xmlns:tns="WSWebService" name="WSWebService" targetNamespace="WSWebService">
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="WSWebService">


      <s:complexType name="WSUserLoginRequest">
          <s:element name="userName" type="s:string" />
          <s:element name="userPassword" type="s:string" />
      <s:complexType name="WSUserLoginResponse">
          <s:element name="userToken" type="s:string" />
          <s:element name="wsdlVersion" type="s:string" minOccurs="1" maxOccurs="1" default="" />
          <s:element name="result" type="s:int" />
          <s:element name="resultString" type="s:string" />


      <wsdl:message name="WSUserLoginSoapIn">
        <wsdl:part name="parameters" type="tns:WSUserLoginRequest" />
      <wsdl:message name="WSUserLoginSoapOut">
        <wsdl:part name="parameters" type="tns:WSUserLoginResponse" />


      <wsdl:operation name="WSUserLogin">
        <wsdl:documentation>Authenticate user using provided username and password.</wsdl:documentation>
        <wsdl:input message="tns:WSUserLoginSoapIn" />
        <wsdl:output message="tns:WSUserLoginSoapOut" />


How to&Answers: