I'm trying to update a program from .NET Framework 4.8 to .NET 8. This program can communicate with RFID tags through SOAP. I've implemented the same WSDL file just like in the old project and auto-generated the code with dotnet-svcutil.
The issue is that the test client doesn't recognize the response, because the structure of the two XML responses are different.
Old response:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<q1:queryPadResponse xmlns:q1="http://webapps.iii.com/wsclient/padrfid">
<queryPadReturn href="#id1"/>
</q1:queryPadResponse>
<q2:QueryRFIDPadResponse id="id1" xsi:type="q2:QueryRFIDPadResponse"
xmlns:q2="http://webapps.iii.com/wsclient/padrfid">
<message xsi:type="xsd:string">
Success.
</message>
<otherErrorOccurred xsi:type="xsd:boolean">
false
</otherErrorOccurred>
<padDown xsi:type="xsd:boolean">
false
</padDown>
<padItems href="#id2"/>
<tooManyItemsOnPad xsi:type="xsd:boolean">
false
</tooManyItemsOnPad>
</q2:QueryRFIDPadResponse>
<q3:Array id="id2" q3:arrayType="q4:PadItem[2]"
xmlns:q3="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:q4="http://webapps.iii.com/wsclient/padrfid">
<Item href="#id3"/>
<Item href="#id4"/>
</q3:Array>
<q5:PadItem id="id3"
xsi:type="q5:PadItem"
xmlns:q5="http://webapps.iii.com/wsclient/padrfid">
<barcode xsi:type="xsd:string">
123456789
</barcode>
<sensitized xsi:type="xsd:boolean">
true
</sensitized>
<setComplete xsi:type="xsd:boolean">
true
</setComplete>
</q5:PadItem>
<q6:PadItem id="id4"
xsi:type="q6:PadItem"
xmlns:q6="http://webapps.iii.com/wsclient/padrfid">
<barcode xsi:type="xsd:string">
12345679
</barcode>
<sensitized xsi:type="xsd:boolean">
true
</sensitized>
<setComplete xsi:type="xsd:boolean">
true
</setComplete>
</q6:PadItem>
</s:Body>
</s:Envelope>
New response:
<s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<s:Body>
<queryPadResponse
xmlns="http://webapps.iii.com/wsclient/padrfid">
<queryPadReturn
xmlns:d4p1="http://schemas.datacontract.org/2004/07/"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<d4p1:message>
Success.
</d4p1:message>
<d4p1:otherErrorOccurred>
false
</d4p1:otherErrorOccurred>
<d4p1:padDown>
false
</d4p1:padDown>
<d4p1:padItems>
<d4p1:PadItem>
<d4p1:barcode>
12345679
</d4p1:barcode>
<d4p1:sensitized>
true
</d4p1:sensitized>
<d4p1:setComplete>
true
</d4p1:setComplete>
</d4p1:PadItem>
<d4p1:PadItem>
<d4p1:barcode>
123456789
</d4p1:barcode>
<d4p1:sensitized>
true
</d4p1:sensitized>
<d4p1:setComplete>
true
</d4p1:setComplete>
</d4p1:PadItem>
</d4p1:padItems>
<d4p1:tooManyItemsOnPad>
false
</d4p1:tooManyItemsOnPad>
</queryPadReturn>
</queryPadResponse>
</s:Body>
</s:Envelope>
The main difference is that the first response always uses ids and the second response is nested.
The test client gives me the following error message: Invalid element in com.iii.webapps.wsclient.padrfid.PadItem - PadItem
If I change the code that it can send only one PadItem and not an array, than the program is working, but in that case I can read only one tag at a time. So the issue has to be somewhere with the PadItem array.
Why is the XML response structured differently? Is there a way get a response similar to the old one? I have no access to the test client code.
UPDATE
In the Program.cs file, in endpoints.UseSoapEndpoint<IQueryRFIDPad>("/sierra", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer); line I chnaged SoapSerializer.DataContractSerializer to SoapSerializer.XmlSerializer. So the code looks like this:
endpoints.UseSoapEndpoint<IQueryRFIDPad>("/sierra", new SoapEncoderOptions(), SoapSerializer.XmlSerializer);
With this change the response looks much more similar to the "old" response:
<s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<s:Body>
<queryPadResponse xmlns="http://webapps.iii.com/wsclient/padrfid">
<q1:QueryRFIDPadResponse id="id1" xmlns:q1="http://webapps.iii.com/wsclient/padrfid">
<message xsi:type="xsd:string" xmlns="">
Success.
</message>
<otherErrorOccurred xsi:type="xsd:boolean" xmlns="">
false
</otherErrorOccurred>
<padDown xsi:type="xsd:boolean" xmlns="">
false
</padDown>
<padItems href="#id2" xmlns=""/>
<tooManyItemsOnPad xsi:type="xsd:boolean" xmlns="">
false
</tooManyItemsOnPad>
</q1:QueryRFIDPadResponse>
<q2:Array id="id2" q2:arrayType="PadItem[2]" xmlns:q2="http://schemas.xmlsoap.org/soap/encoding/">
<Item href="#id3" xmlns=""/>
<Item href="#id4" xmlns=""/>
</q2:Array>
<q3:PadItem id="id3" xsi:type="q3:PadItem" xmlns:q3="http://webapps.iii.com/wsclient/padrfid">
<barcode xsi:type="xsd:string" xmlns="">
123456789
</barcode>
<sensitized xsi:type="xsd:boolean" xmlns="">
true
</sensitized>
<setComplete xsi:type="xsd:boolean" xmlns="">
true
</setComplete>
</q3:PadItem>
<q4:PadItem id="id4" xsi:type="q4:PadItem" xmlns:q4="http://webapps.iii.com/wsclient/padrfid">
<barcode xsi:type="xsd:string" xmlns="">
12345679
</barcode>
<sensitized xsi:type="xsd:boolean" xmlns="">
true
</sensitized>
<setComplete xsi:type="xsd:boolean" xmlns="">
true
</setComplete>
</q4:PadItem>
</queryPadResponse>
</s:Body>
</s:Envelope>
The error message from the test client that I get now is: org.xml.sax.SAXException: Bad types (class [Ljava.lang.Object; -> class com.iii.webapps.wsclient.padrfid.QueryRFIDPadResponse).