dotnet / dotnet/wcf

dotnet-svcutil silently failing to deserialize responses

Open
#4,163 17 comments 5 reactions 1 assignee Assigned to @mconnew View on GitHub
bug investigation needed vnext consider
Dominant language
C#
Stars
1.8k
Forks
576
Avg merge
6d 9h
Merged PRs (30d)
2

Description

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

```csharp
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
``` csharp
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.
``` wsdl


...














...






...


Authenticate user using provided username and password.



```

![Request](https://user-images.githubusercontent.com/1694687/74494837-d8eac100-4f21-11ea-8125-5b3f331f358a.png)
![Response](https://user-images.githubusercontent.com/1694687/74494840-dd16de80-4f21-11ea-8846-a5142b33e285.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.