Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XmlSerializer WSDL for DateTimeOffset invalid #1013

Closed
vidrenning opened this issue Feb 8, 2024 · 0 comments · Fixed by #1014
Closed

XmlSerializer WSDL for DateTimeOffset invalid #1013

vidrenning opened this issue Feb 8, 2024 · 0 comments · Fixed by #1014

Comments

@vidrenning
Copy link
Contributor

Let's say there is a type such as the following:

public class Hello
{
    public DateTimeOffset TimeStamp { get; set; } = DateTimeOffset.Now;
}

SoapCore currently will generate the following WSDL for it:

<xsd:complexType name="Hello">
  <xsd:sequence>
    <xsd:element xmlns:q1="http://schemas.datacontract.org/2004/07/System" minOccurs="1" maxOccurs="1" name="TimeStamp" type="q1:DateTimeOffset"/>
  </xsd:sequence>
</xsd:complexType>

and further below:

<xsd:schema xmlns:tns="http://schemas.datacontract.org/2004/07/System" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/System">
  <xsd:import namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
  <xsd:complexType name="DateTimeOffset">
    <xsd:annotation>
      <xsd:appinfo>
        <IsValueType xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</IsValueType>
      </xsd:appinfo>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:element minOccurs="1" maxOccurs="1" name="DateTime" type="xsd:dateTime"/>
      <xsd:element minOccurs="1" maxOccurs="1" name="OffsetMinutes" type="xsd:short"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:element name="DateTimeOffset" nillable="true" type="tns:DateTimeOffset"/>
</xsd:schema>

This schema corresponds to the XML that the DataContractSerializer generates, but it does not correspond to the XML that the XmlSerializer generates.

The actual SOAP XML that is transferred is the following:

<Hello>
  <TimeStamp>2024-02-08T09:55:41.2527621+01:00</TimeStamp>
</Hello>

As you can see, the XML generated by the XmlSerializer does not correspond to the WSDL that is generated.

vidrenning added a commit to vidrenning/SoapCore that referenced this issue Feb 8, 2024
XmlSerializer will serialize a DateTimeOffset simply as a string.

Adjusted the DateTimeOffset test so that it works for both,
DataContractSerializer and XmlSerializer.

Fixes DigDes#1013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant