We need to call a SOAP service.
Unfortunately the WSDL generated code does not work as expected because they require MTOM which causes problems we have not been able to resolve. So we are forced to reinvent wheels and I'm trying to figure out the best (or at least a good way) to do this.
The SOAP service will create a response like:
--uuid:d49971de-e2c2-4af4-947d-c0acc0f6ad64
Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml"
Content-Transfer-Encoding: binary
Content-ID:
<root.message@cxf.apache.org>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<ns2:listAttachmentsResponse xmlns:ns2="http://ws.praxedo.com/v6/businessEvent">
<return>
<resultCode>0</resultCode>
<entities>
<entityId>00044</entityId>
<name>JohnDoe.pdf</name>
<addedOnDevice>false</addedOnDevice>
<creationDate>2021-03-17T20:48:36.849+01:00</creationDate>
<external>false</external>
<id>1103057659_1500033662_C_05126a814b440b8c6efea0d195cbae8f</id>
<lastModificationDate>2021-05-04T20:38:42.829+02:00</lastModificationDate>
<size>249794</size>
<unmodifiable>false</unmodifiable>
</entities>
<entities>
<entityId>00044</entityId>
<name>OAY3PD.pdf</name>
<addedOnDevice>false</addedOnDevice>
<creationDate>2021-03-17T20:48:36.829+01:00</creationDate>
<external>false</external>
<id>1103057659_1500033662_C_04870c813b0c352bed5213425a946d5c</id>
<lastModificationDate>2021-05-04T20:38:42.829+02:00</lastModificationDate>
<size>465275</size>
<unmodifiable>false</unmodifiable>
</entities>
</return>
</ns2:listAttachmentsResponse>
</soap:Body>
</soap:Envelope>
--uuid:d49971de-e2c2-4af4-947d-c0acc0f6ad64--
Is there a convenient or idiomatic way of extracting the Xml we care about from this response, or do we need to create custom logic to dispose of the boundary and content metadata?
How do I deal with the different namespaces and aliases, and lack thereof, as well as the element named "return"?
I'd like for the result to be a POCO, possibly something like:
public class ListAttachmentsResponse {
public int ResultCode { get; init; }
public Attachment[] Attachments
}
public class Attachment {
// This is the "entityId", we need to keep the leading zeros.
public string BusinessEventId { get; init; }
public string FileName { get; init; }
public bool IsAddedOnDevice { get; init; }
public DateTime CreationDate { get; init; }
public bool IsExternal { get; init; }
public string Id { get; init; }
public DateTime LastModificationDate { get; init; }
public int size { get; init; }
public bool IsUnmodifiable { get; init ;}
}
... but I can be flexible about the structure if something else would be easier to retrieve.