Hello,
My problem is kind of hard to explain so I hope the title attracts the right people.
I am building an XDocument which I then want to deserialize into a web service object to send to the service. My problem is I don't know how to deserialize the XDocument to match the SOAP Message because of the multiple namespaces. What I am currently trying is to deserialize each lower level object then add them back together but that isn't working. Any help would be greatly appreciated.
XDocument:
<ns0:TripTenders xmlns:ns0="http://www.tsgsolutions.com/biztalk/schemas/TripTenders">
<ns1:TripTender xmlns:ns1="http://www.tsgsolutions.com/biztalk/schemas/TripTender">
<CompanyID>1024</CompanyID>
<Reference>204Schema Test</Reference>
<Contact>Shane</Contact>
<TotalMiles>1086</TotalMiles>
<Weight>10000</Weight>
<CurrentStatus>18</CurrentStatus>
<TripNum>57652</TripNum>
<CarrierID>28354</CarrierID>
</ns1:TripTender>
</ns0:TripTenders>
SOAP Message:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Operation_1 xmlns="http://tempuri.org/">
<TripTenders xmlns="http://www.tsgsolutions.com/biztalk/schemas/TripTenders">
<TripTender xmlns="http://www.tsgsolutions.com/biztalk/schemas/TripTender">
<CompanyID xmlns="">int</CompanyID>
<Reference xmlns="">string</Reference>
<Contact xmlns="">string</Contact>
<TotalMiles xmlns="">int</TotalMiles>
<Weight xmlns="">decimal</Weight>
<CurrentStatus xmlns="">int</CurrentStatus>
<TripNum xmlns="">string</TripNum>
<CarrierID xmlns="">int</CarrierID>
</TripTender>
<TripTender xmlns="http://www.tsgsolutions.com/biztalk/schemas/TripTender">
<CompanyID xmlns="">int</CompanyID>
<Reference xmlns="">string</Reference>
<Contact xmlns="">string</Contact>
<TotalMiles xmlns="">int</TotalMiles>
<Weight xmlns="">decimal</Weight>
<CurrentStatus xmlns="">int</CurrentStatus>
<TripNum xmlns="">string</TripNum>
<CarrierID xmlns="">int</CarrierID>
</TripTender>
</TripTenders>
</Operation_1>
</soap:Body>
</soap:Envelope>
Current Logic:
XDocument xml = PopulateXML();
var btTripTenders = new List<BizTalk204.TripTender>();
var btTripTender = new BizTalk204.TripTender();
string namespace1URI = "http://www.tsgsolutions.com/biztalk/schemas/TripTender";
var ser = new System.Xml.Serialization.XmlSerializer(btTripTender.GetType(), namespace1URI);
foreach (var tripTender in xml.Root.Elements(XName.Get("TripTender", namespace1URI)))
{
using (var reader = tripTender.CreateReader())
{
reader.MoveToContent();
btTripTenders.Add((BizTalk204.TripTender)ser.Deserialize(reader));
}
}
var bizRtn = _bizTalk204.Operation_1(btTripTenders.ToArray());