dotnet / wcf

This repo contains the client-oriented WCF libraries that enable applications built on .NET Core to communicate with WCF services.
MIT License
1.72k stars 558 forks source link

Missing base64 attribute in request from "dotnet-svcutil" generated client #4069

Open scrodde opened 5 years ago

scrodde commented 5 years ago

Bug: The generated client request is missing the xsi:type="n1:base64" xmlns:n1="http://schemas.xmlsoap.org/soap/encoding/" attribute on its <file /> element. The attribute specification is defined in the schema.

Schema: https://testing.maventa.com/apis/v1.1/wsdl

...
<xsd:complexType name=“FileAttachment”>
 <xsd:all>
   <xsd:element name=“file” type=“soapenc:base64”/>
   <xsd:element name=“attachment_type” type=“xsd:string”/>
   <xsd:element name=“filename” type=“xsd:string”/>
 </xsd:all>
</xsd:complexType>
...

Generated request:

...
<q3:FileAttachment id=\"id2\" xsi:type=\"q3:FileAttachment\" 
  xmlns:q3=\"https://secure.maventa.com/\">
 <file>77u/PD94bWwgdmVyc2lvbj0iMS4wIi...ZvaWNlPg==</file>
  <filename xsi:type=\"xsd:string\">invoice1341515351353135.xml</filename>
</q3:FileAttachment>
...

Expected request:

...
<q3:FileAttachment id="id2" xsi:type="q3:FileAttachment" 
  xmlns:q3="https://secure.maventa.com/">
  <file xsi:type="n1:base64"    
xmlns:n1="http://schemas.xmlsoap.org/soap/encoding/">77u/PD94bWwgdmVyc2lvbj0iMS4wIi...ZvaWNlPg==</file>
  <filename xsi:type="xsd:string">invoice1341515351353135.xml</filename>
</q3:FileAttachment>
...

WSDL: https://testing.maventa.com/apis/v1.1/wsdl Version: [Microsoft.Tools.ServiceModel.Svcutil, Version 2.0.0]


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

mairaw commented 5 years ago

@mlacouture can you review this issue? This seems like a product bug. Should it be moved somewhere else?

mlacouture commented 5 years ago

@dasetser who owns this now.

dasetser commented 5 years ago

@scrodde Since this issue is for the product rather than the documentation please open an issue on the WCF Core Github: https://github.com/dotnet/wcf/. When you open that issue can you also include information on if this works correctly if you use the normal svcutil and a full framework client? If we can confirm there's a difference in behavior it will be easier for us to investigate the cause of this.

mairaw commented 4 years ago

I've transferred the issue to the requested repo @dasetser.

tonihele commented 3 years ago

@scrodde did you manage to work your way around this? Seems that we are contacting the exact same endpoint and hit this very issue...

HongGit commented 2 years ago

@imcarolwang can you please see if there is behavior change from .NET framework?

imcarolwang commented 2 years ago

There is behavior change from Framework in XmlSerializerserializing byte[] type to soap xml.

In .Net Core, for a target class FileAttachmentwhich has SoapTypeAttributeapplied, if its public property byte[] File has applied [SoapElement(DataType = "base64Binary")] or none, the serialization result would be missing XsiType info, if applying the property with [SoapElement(DataType = "hexBinary")] then the XsiType info would be generated when serialized.

In .Net Framework, XsiType is always generated for the byte[] property in the serialization result as long as its containing class has SoapTypeAttributeapplied.

repro.txt