wcf icon indicating copy to clipboard operation
wcf copied to clipboard

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

Open scrodde opened this issue 6 years ago • 7 comments
trafficstars

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.

scrodde avatar May 08 '19 10:05 scrodde

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

mairaw avatar May 20 '19 22:05 mairaw

@dasetser who owns this now.

mlacouture avatar May 20 '19 22:05 mlacouture

@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.

dasetser avatar May 21 '19 17:05 dasetser

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

mairaw avatar Dec 06 '19 06:12 mairaw

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

tonihele avatar Sep 17 '21 13:09 tonihele

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

HongGit avatar Apr 13 '22 02:04 HongGit

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

In .Net Core, for a target class FileAttachment which has SoapTypeAttribute applied, 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 SoapTypeAttribute applied.

repro.txt

imcarolwang avatar Apr 19 '22 08:04 imcarolwang