I find it a huge pain having to write serialization mappings for XML / SOAP services.
QuickType has saved me a huge amount of time with mappings for JSON and so I would like to propose that QuickType be extended to also support XML / SOAP and potentially WSDL
Input:
SOAP:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<SomeRequest>
<SomeProperty>1</SomeProperty>
<OtherProperty>Hello</OtherProperty>
</SomeRequest>
</soapenv:Body>
</soapenv:Envelope>
OR
WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions http:force="" name="ServiceOrEndpointName" targetNamespace="NameSpace" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="NameSpace" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:documentation>
Documentation about the service
</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="SomeRequest" type="SomeRequestType">
<xs:annotation>
<xs:documentation>Some Documentation for this request</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="SomeRequestType">
<xs:annotation>
<xs:documentation>Documentation about this type</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element form="unqualified" name="SomeProperty" type="xs:int"/>
<xs:element form="unqualified" name="OtherProperty" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
</wsdl:definitions>
Output:
C#:
namespace QuickType
{
[SoapType("SomeRequestType")]
public class SomeRequest
{
[SoapElement("SomeProperty")]
public int SomeProperty { get; set; }
[SoapElement("OtherProperty")]
public string OtherProperty { get; set; }
}
public static class Converter
{
public static string SerializeObject<T>(T serialize)
{
var stringWriter = new StringWriter();
new XmlSerializer(typeof(T)).Serialize(stringWriter,serialize);
return stringWriter.ToString();
}
public static object DeserializeObject<T>(string serialized) => new XmlSerializer(typeof(T)).Deserialize(new StringReader(serialized));
}
}
I find it a huge pain having to write serialization mappings for XML / SOAP services.
QuickType has saved me a huge amount of time with mappings for JSON and so I would like to propose that QuickType be extended to also support XML / SOAP and potentially WSDL
Input:
SOAP:
OR
WSDL:
Output:
C#: