The auto-generated WCF classes created by visual studio are not deserializing a SOAP response correctly for an endpoint I am using. It is returning null for an object that is definitely being returned to the the service.
Is there a way to work around this by getting the raw XML response from the SOAP call? Or is there some other way I can handle this problem?
I have a similar issue. I am consuming a SOAP endpoint which has two methods. Both return a Message Body of different array type but have the same serialization properties.
I have two actions in the SOAP endpoint. getAddresses and getActiveProducts. When I call getAddresses I get back the response from the endpoint (I can see that in the Fiddler). But while deserialization, instead of converting it to AddressWSO[], it tries to convert it to ProductWSO[] and gives me the following error.
"message": "Object of type 'MyNameSpace.ProductWSO[]' cannot be converted to type 'MyNameSpace.AddressWSO[]'.",
"exceptionType": "System.ArgumentException",
"stackTrace": " at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)\r\n at System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, StackCrawlMark& stackMark)\r\n at System.Reflection.RtFieldInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)\r\n at System.ServiceModel.Dispatcher.OperationFormatter.TypedMessageParts.SetValue(Object value, Int32 index)\r\n at System.ServiceModel.Dispatcher.OperationFormatter.TypedMessageParts.SetTypedMessageParts(Object[] values)\r\n at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)\r\n at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc)\r\n at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)\r\n at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)\r\n at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.<CreateGenericTask>b__0(IAsyncResult asyncResult)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n
Here is the response returned from the SOAP endpoint.
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:getAddressesResponse xmlns:ns1="http://mynamespace.com/">
<return>
<item>
<city>MyCity</city>
<country />
<ID>1123456</ID>
<state>MI</state>
<street>123 My Street Lane</street>
<type>Physical</type>
<zip>12345</zip>
</item>
<item>
<city>MyCity</city>
<country />
<ID>1123456</ID>
<state>MI</state>
<street>123 My Street Lane</street>
<type>Shipping</type>
<zip>12345</zip>
</item>
<item>
<city>MyCity</city>
<country />
<ID>1123456</ID>
<state>MI</state>
<street>123 My Street Lane</street>
<type>Mailing</type>
<zip>12345</zip>
</item>
<item>
<city>MyCity</city>
<country />
<ID>1123456</ID>
<state>MI</state>
<street>123 My Street Lane</street>
<type>Billing</type>
<zip>12345</zip>
</item>
</return>
</ns1:getAddressesResponse>
</soap:Body>
</soap:Envelope>
Here is the Code for ServiceClient
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// //
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MyNameSpace
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
[System.ServiceModel.ServiceContractAttribute(Namespace = "http://mynamespace.com/", ConfigurationName = "MyWebServiceImpl")]
public interface MyWebServiceImpl
{
[System.ServiceModel.OperationContractAttribute(Action = "", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ProductWSO[]))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(AddressWSO[]))]
System.Threading.Tasks.Task<MyNameSpace.getActiveProductsResponse> getActiveProductsAsync(MyNameSpace.getActiveProducts request);
[System.ServiceModel.OperationContractAttribute(Action = "", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(AddressWSO[]))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(AddressWSO[]))]
System.Threading.Tasks.Task<MyNameSpace.getAddressesResponse> getAddressesAsync(MyNameSpace.getAddresses request);
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
public interface MyWebServiceImplChannel : MyWebServiceImpl, System.ServiceModel.IClientChannel
{
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
public partial class MyWebServiceImplClient : System.ServiceModel.ClientBase<MyWebServiceImpl>, MyWebServiceImpl
{
/// <summary>
/// Implement this partial method to configure the service endpoint.
/// </summary>
/// <param name="serviceEndpoint">The endpoint to configure</param>
/// <param name="clientCredentials">The client credentials</param>
static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials);
public MyWebServiceImplClient() :
base(MyWebServiceImplClient.GetDefaultBinding(), MyWebServiceImplClient.GetDefaultEndpointAddress())
{
this.Endpoint.Name = EndpointConfiguration.MyWebServiceImplPort.ToString();
ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
}
public MyWebServiceImplClient(EndpointConfiguration endpointConfiguration) :
base(MyWebServiceImplClient.GetBindingForEndpoint(endpointConfiguration), MyWebServiceImplClient.GetEndpointAddress(endpointConfiguration))
{
this.Endpoint.Name = endpointConfiguration.ToString();
ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
}
public MyWebServiceImplClient(EndpointConfiguration endpointConfiguration, string remoteAddress) :
base(MyWebServiceImplClient.GetBindingForEndpoint(endpointConfiguration), new System.ServiceModel.EndpointAddress(remoteAddress))
{
this.Endpoint.Name = endpointConfiguration.ToString();
ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
}
public MyWebServiceImplClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
base(MyWebServiceImplClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
{
this.Endpoint.Name = endpointConfiguration.ToString();
ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
}
public MyWebServiceImplClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress)
{
}
public System.Threading.Tasks.Task<MyNameSpace.getActiveProductsResponse> getActiveProductsAsync(MyNameSpace.getActiveProducts request)
{
return base.Channel.getActiveProductsAsync(request);
}
public System.Threading.Tasks.Task<MyNameSpace.getAddressesResponse> getAddressesAsync(MyNameSpace.getAddresses request)
{
return base.Channel.getAddressesAsync(request);
}
public virtual System.Threading.Tasks.Task OpenAsync()
{
return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(null, null), new System.Action<System.IAsyncResult>(((System.ServiceModel.ICommunicationObject)(this)).EndOpen));
}
public virtual System.Threading.Tasks.Task CloseAsync()
{
return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginClose(null, null), new System.Action<System.IAsyncResult>(((System.ServiceModel.ICommunicationObject)(this)).EndClose));
}
private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
{
if ((endpointConfiguration == EndpointConfiguration.MyWebServiceImplPort))
{
System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
result.MaxBufferSize = int.MaxValue;
result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
result.MaxReceivedMessageSize = int.MaxValue;
result.AllowCookies = true;
result.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
return result;
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}
private static System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration)
{
if ((endpointConfiguration == EndpointConfiguration.MyWebServiceImplPort))
{
return new System.ServiceModel.EndpointAddress("https://endpoint.com");
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}
private static System.ServiceModel.Channels.Binding GetDefaultBinding()
{
return MyWebServiceImplClient.GetBindingForEndpoint(EndpointConfiguration.MyWebServiceImplPort);
}
private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
{
return MyWebServiceImplClient.GetEndpointAddress(EndpointConfiguration.MyWebServiceImplPort);
}
public enum EndpointConfiguration
{
MyWebServiceImplPort,
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
[System.ServiceModel.MessageContractAttribute(WrapperName = "getActiveProducts", WrapperNamespace = "http://mynamespace.com/", IsWrapped = true)]
public partial class getActiveProducts
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "getActiveProducts", Order = 0)]
public int arg0;
public getActiveProducts()
{
}
public getActiveProducts(int arg0)
{
this.arg0 = arg0;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
[System.ServiceModel.ServiceKnownType(typeof(ProductWSO))]
[System.ServiceModel.ServiceKnownType(typeof(ProductWSO[]))]
[System.ServiceModel.MessageContractAttribute(WrapperName = "getActiveProductsResponse", WrapperNamespace = "http://mynamespace.com/", IsWrapped = true)]
public partial class getActiveProductsResponse
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "", Order = 0)]
[System.Xml.Serialization.XmlArrayAttribute("return")]
[System.Xml.Serialization.XmlArrayItemAttribute("item", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public MyNameSpace.ProductWSO[] @return;
public getActiveProductsResponse()
{
}
public getActiveProductsResponse(MyNameSpace.ProductWSO[] @return)
{
this.@return = @return;
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://mynamespace.com/")]
public partial class ProductWSO
{
private string expiratinDateDisplayStringField;
private System.Nullable<System.DateTime> expirationDateField;
private bool expirationDateFieldSpecified;
private string licenseTypeField;
private string licenseeField;
private string networkTypeField;
private string productCodeField;
private string productFamilyField;
private string productNameField;
private string seatsField;
private string supportField;
private string unitsField;
private string versionField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 0)]
public string expiratinDateDisplayString
{
get
{
return this.expiratinDateDisplayStringField;
}
set
{
this.expiratinDateDisplayStringField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable = true, Order = 1)]
public System.Nullable<System.DateTime> expirationDate
{
get
{
return this.expirationDateField;
}
set
{
this.expirationDateField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool expirationDateSpecified
{
get
{
return this.expirationDateFieldSpecified;
}
set
{
this.expirationDateFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 2)]
public string licenseType
{
get
{
return this.licenseTypeField;
}
set
{
this.licenseTypeField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 3)]
public string licensee
{
get
{
return this.licenseeField;
}
set
{
this.licenseeField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 4)]
public string networkType
{
get
{
return this.networkTypeField;
}
set
{
this.networkTypeField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 5)]
public string productCode
{
get
{
return this.productCodeField;
}
set
{
this.productCodeField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 6)]
public string productFamily
{
get
{
return this.productFamilyField;
}
set
{
this.productFamilyField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 7)]
public string productName
{
get
{
return this.productNameField;
}
set
{
this.productNameField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 8)]
public string seats
{
get
{
return this.seatsField;
}
set
{
this.seatsField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 9)]
public string support
{
get
{
return this.supportField;
}
set
{
this.supportField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 10)]
public string units
{
get
{
return this.unitsField;
}
set
{
this.unitsField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 11)]
public string version
{
get
{
return this.versionField;
}
set
{
this.versionField = value;
}
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
[System.ServiceModel.MessageContractAttribute(WrapperName = "getAddresses", WrapperNamespace = "http://mynamespace.com/", IsWrapped = true)]
public partial class getAddresses
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "getAddresses", Order = 0)]
public int arg0;
public getAddresses()
{
}
public getAddresses(int arg0)
{
this.arg0 = arg0;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
[System.ServiceModel.ServiceKnownType(typeof(AddressWSO))]
[System.ServiceModel.ServiceKnownType(typeof(AddressWSO[]))]
[System.ServiceModel.MessageContractAttribute(WrapperName = "getAddressesResponse", WrapperNamespace = "http://mynamespace.com/", IsWrapped = true)]
public partial class getAddressesResponse
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "", Order = 0)]
[System.Xml.Serialization.XmlArrayAttribute("return")]
[System.Xml.Serialization.XmlArrayItemAttribute("item", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public MyNameSpace.AddressWSO[] @return;
public getAddressesResponse()
{
}
public getAddressesResponse(MyNameSpace.AddressWSO[] @return)
{
this.@return = @return;
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://mynamespace.com/")]
public partial class AddressWSO
{
private string cityField;
private string contactField;
private string countryField;
private string firmNameField;
private int idField;
private string stateField;
private string streetField;
private string street2Field;
private string typeField;
private string zipField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 0)]
public string city
{
get
{
return this.cityField;
}
set
{
this.cityField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 1)]
public string contact
{
get
{
return this.contactField;
}
set
{
this.contactField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 2)]
public string country
{
get
{
return this.countryField;
}
set
{
this.countryField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 3)]
public string firmName
{
get
{
return this.firmNameField;
}
set
{
this.firmNameField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 4)]
public int ID
{
get
{
return this.idField;
}
set
{
this.idField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 5)]
public string state
{
get
{
return this.stateField;
}
set
{
this.stateField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 6)]
public string street
{
get
{
return this.streetField;
}
set
{
this.streetField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 7)]
public string street2
{
get
{
return this.street2Field;
}
set
{
this.street2Field = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 8)]
public string type
{
get
{
return this.typeField;
}
set
{
this.typeField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 9)]
public string zip
{
get
{
return this.zipField;
}
set
{
this.zipField = value;
}
}
}
}
@jugg1es Is your problem similar with @nishantkagrawal's?
@jugg1es Is your problem similar with @nishantkagrawal's?
No, I wish I was getting an error. My problem is that the serialized response is not serializing nested data and just returning null for a nested property on the response. The non-nested properties return fine. The auto-generated classes in .NET framework 4.7.1 worked fine with the same WSDL and endpoint but in .NET core, part of the response is just returning as null.
I dug through the auto-generated classes and could not find any issue. It all looks correct to me. This isn't the first time the .NET core auto-generated classes didn't work but I was able to find an issue in the generated code and was able to fix it. I could not find anything to fix this time.
The serialization seems is too black-boxed for me to intercept the serialization process. If there was an easy way to intercept the response, I might be able to determine what the issue is.
This is the WSDL
wsdl.txt
This is an example of the response that is not serializing that I got from SOAP UI
I'm using .net core 2.1
I also have a problem with deserialization. But in my case I have " the response message does not match the content type of the binding" - if the source code is closed and there is so many problem with deserialization. Couldn't you give us a future that generate also functions that return string so we could easly make our own function to de serialize this?
I too have a similar issue, where in .net framework it works with the same request but in .net core the complex business object fails to deserialize into an object, any update on this issue ?
[dotnet core]
Same issue there with dotnet-svcutil (1.0.0.1 & 2.0.0).
When deserializing the SOAP response all fields are empty.
Inside the generated Reference.cs files, properties have the XmlElementAttribute attribute:
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
If I remove the Form argument, it seems to work:
[System.Xml.Serialization.XmlElementAttribute(Order=0)]
There are a few problems reported in this issue all related to deserialization, but most likely with different root causes. I'll try to go through each, but I would suggest opening a new issue with as much information as you can if you need them to be investigated. Feel free to link to this issue if you think it has a similar root cause.
In general, if you are having problems with getting null objects back from deserialization the data you're deserializing doesn't match the type you're trying to deserialize it to for some reason. In this issue I believe you all are reporting that it works on full framework but not on .NET Core. A few possible reasons for this are:
1) There's some mismatch from the service. For example sending data that doesn't match the wsdl it defines.
2) The type isn't serializable in .NET Core. For example we ran into this in issue #2307. Some types are marked as Serializable in the full framework but not .NET Core.
3) There's a bug in the .NET Core serialization code, or a bug in the tools that generated the proxy code (WCF Connected Service or dotnet-svcutil) so they don't match the data.
@jugg1es Thanks for providing the response and WSDL. This does look like a bug and we're currently investigating how to fix it. Unfortunately I don't know of any workaround right now, but I'll update this issue once we can investigate this more.
@nishantkagrawal This looks different from the problem jugg1es is facing. Can you please open a new issue? This may be a problem with WCF Core rather than with serialization. The callstack looks like we're trying to deserialize it to the wrong type for some reason, so it makes sense the deserializion is failing. When you open the new issue if you can provide the wsdl for the service it would be helpful in determining the problem.
@xnivel This sounds like a different issue. Can you please open a new issue and provide any additional information you can? For example if the error message says what the content mismatch is, or if you can look at what the response you're getting is and include it that would be helpful. This can be caused by something like the client's setup not matching the service's config. If you really need to do something with the response before deserialization you could look at some of WCF's extensibility like a message inspector, but this sounds like a configuration problem rather than a bug in the deserialize code.
@coderookie1994 Have you looked at which part of the object is failing to deserialize? Is the code generated by dotnet-svcutil the same as what's generated by normal svcutil? If you can provide the wsdl and request that's failing we can try to see what the problem is. Alternatively if you can narrow down which part of the object is failing it would help point us in the right direction.
@dhabierre This looks like a different problem from the original reported in this issue. Can you please open a new issue so we can investigate this more? If possible can you include the WSDL and/or response? Does this work on full framework WCF using normal svcutil.exe? If so does that include the Form argument?
@dasetser I have added information to the existing bugs that I found already. I am not sure if you still want me to open up a new issue.
@nishantkagrawal I didn't realize you had added information to both of those. Your issue does sound like it's probably the same bug as #3171, so I would suggest following that issue and you don't need to worry about opening a new one. 2804 has a similar symptom to some problems reported in this issue, but it's failing for a different reason.
Hello !!
I have same issue like jugg1es. The SOAP response in VS 2019 is returning null for an object that is definitely being returned to the the service.
Here is my wsdl. sageX3wsdl.txt
and the Response... sageX3Response.txt
Thanks for your help!
I use .NETCore.Platforms 2.0.0 (NETStandard.Library 2.0.3)
The deserialization works on full framework but not on .NET Core.
Klaus
Updated the title of this Issue to be more specific, this issue tracks the problem described by @jugg1es and is currently targeting the 3.0 release.
@kks78 Thanks for reporting your issue and providing the wsdl and response.
Hello,
Is there any set deadline on fixing this?
I'm wondering whether to wait or to begin on a workaround.
@jpommers We had intended to get this done sooner, but have had some higher priority work to get done first. We are now planning to get it done in 3.1 servicing. 3.1 GA will be in early December, so the earliest would be January.
How would we work around this issue? @jpommers any ideas?
@paviad I wrote a class that implements the service contract interface and uses HttpClient to send manually serialized xml. This way when the fix actually comes in all i have to do is change the DI configuration.
Hi,
What is the last status on this issue? I am facing the same problem. I generated a connected service in .net core app. The proxy always returns null values even-though SOAP service is returning valid response. There are no errors thrown from de-serialization code.
If no solution exists, what is the workaround?
@mthalman here my workaround:
https://github.com/dotnet/wcf/issues/3228#issuecomment-477645501
Hope this help
I found the issue. I guess there is a bug in svcutil that generates proxy class (connected service?) in .net core. The MessageContractAttribute WrapperName must match name of class that it is used for.
[System.ServiceModel.MessageContractAttribute(WrapperName=
If it does not match the name of class, the de-serialization fails to generate object from SOAP response.
@mtinwala i had the same issue. Changing the Wrapper and Namespace name solved it ....
Somewhat unrelated with main thread but anyways relevant. Now, I am having a new issue with de-serialization of SOAP headers. I am using SoapCore to set up my .net core SOAP service. This may or may not be a reason. Is there any way to grab SOAP headers via auto-generated proxy class without having to do low-level webclient requests?
Is there any improvement about this ?
Going more deeply, in my case looks like the XSD from WSDL has the last item with a restriction from a "genericField" type, that is another XSD.
I just realized when I imported the WSDL there were some warnings:
Validation Error: Invalid particle derivation by restriction - 'Derived element 'www.hexfield.acquirer.aci.com:value' is not a valid restriction of base element 'www.genericfield.acquirer.aci.com:value' according to Elt:Elt -- NameAndTypeOK.'
When I changed in Reference.cs the field type to string and "forced" the SOAP to return a string instead of a genericField type, it worked fine.
I'm not sure what should be the solution for this case.
Can someone give code example how to make manual soap request to the server ?
Hi, has there been any update to this issue? I have the exact same problem on Core 3.1. The issue has been open for 2 years, would really appreciate some positive feedback.
I believe this is planned for .NET 6, @HongGit and @StephenMolloy
XmlElementAttribute
sadly doen't work on my project...
Change:
[System.ServiceModel.XmlSerializerFormatAttribute(Style=System.ServiceModel.OperationFormatStyle.Rpc, SupportFaults=true, Use=System.ServiceModel.OperationFormatUse.Encoded)]
To
[System.ServiceModel.XmlSerializerFormatAttribute(Style=System.ServiceModel.OperationFormatStyle.Document, SupportFaults=true, Use=System.ServiceModel.OperationFormatUse.Literal)]
Most helpful comment
I too have a similar issue, where in .net framework it works with the same request but in .net core the complex business object fails to deserialize into an object, any update on this issue ?