Skip to content

dotnet-svcutil silently failing to deserialize responses #4163

Open
@brent-williams

Description

@brent-williams

Describe the bug
The proxy from dotnet-svcutil connects to the server, serializes and sends a request ok, and elicits a correct response from WFC server. But deserialization fails without error and I simply get null returned. Under .NET Framework 4.8 the wsdl.exe-generated proxy there is deserializing fine.

To Reproduce
The SOAP server is fixed and beyond my control. However, I have captured the relevant SOAP request & response in Fiddler, attached with the relevant WSDL. Connect/operation code below, nothing special. Note in main() I am using @shmao's workaround from #2219 to avoid the 'JScript/CSharp scripts is not supported' proxy exception i.e.:

            MethodInfo method = typeof(XmlSerializer).GetMethod("set_Mode", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
            method.Invoke(null, new object[] { 1 });

Proxy generated with dotnet-svcutil --sync --outputDir . http://XXX/?WSDL. The generated proxy fails to generate unless all Namespace="" attribute arguments are removed, possibly related. I added EventListener and dumping everything down Verbose from all event sources, lots of output but nothing at all around the deserialization failure.

Putting dotnet-svcutil aside I wrote manual Channel-based MessageContract/DataContract wrappers, ultimately I get the same null result. I am unable to shape the Response classes so that attached SOAP response will deserialize under WCF with a non-null result.

Confirmed the null result occurs using dotnet-svcutil 2.0.1 with System.ServiceModel.* 4.7.0 under both .NET Core 3.0 and 3.1 on both Windows 10 and macOS Catalina.

Expected behavior
A populated response object. Failing that, an exception to help narrow down the problem. Failing that, even just some hack to get at the raw response string in case of failure, that way I could at least use the proxy for requests & tear apart the response manually (regex/xpath/etc.).

Screenshots
Attached fiddler.

Additional context
Connection code

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

        await proxy.OpenAsync();
      } catch (Exception e) {
        Console.WriteLine(e.Message);
        return;
      }

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

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

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

Relevant WSDL, can send in full on private channel if required.

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
  xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
  xmlns:s="http://www.w3.org/2001/XMLSchema" 
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
  xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" 
  xmlns:tns="WSWebService" name="WSWebService" targetNamespace="WSWebService">
  <wsdl:types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="WSWebService">

      ...

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

      ...

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

      ...

      <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" />
      </wsdl:operation>

Request
Response

Metadata

Metadata

Assignees

Labels

bugThis is a product bug.investigation neededAdditional investigation needed before issue can be triaged.vnext considerFeature requests or Bugs to consider taking in vNext.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions