I contact a web service that returns something like 2600 records in SOAP format. To do some integration testing, I saved the soap message by copying the result from SoapUi to a file. I then removed most of the records (identified as Report_Entry) to give myself a much smaller test.
So, I'm writing a unit test that loads the file as XML:
XmlSerializer deSerialize = new XmlSerializer(typeof(List<Report_EntryType>));
(The WSDL defines the entries as Report_EntryType.)
Then:
{
workdayList = deSerialize.Deserialize(reader) as List<Report_EntryType>;
}
But, my test fails on a
System.InvalidOperationException : <Envelope xmlns='http://schemas.xmlsoap.org/soap/envelope/'>
To summarize:
- Retrieve a SOAP message from a webservice.
- Save the message to a file.
- Remove most of the records from the test file so I only have one or two.
- Feed that file to a test case that uses XmlSerializer to give me input data.
- Use a string reader to read the input data.
- Blow up when trying to deserialize.
How do I solve the problem?
Sample file:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<wd:report_data xmlns:wd="urn:com.workday.report/wog_workday_to_ad_integration_report:2">
<wd:Report_Entry>
<wd:Employee_ID>99995</wd:Employee_ID>
<wd:Manager_ID>001961</wd:Manager_ID>
<wd:Full_Legal_Name>Luke Skywalker</wd:Full_Legal_Name>
<wd:Legal_Name_-_First_Name>Luke</wd:Legal_Name_-_First_Name>
<wd:Legal_Name_-_Last_Name>Skywalker</wd:Legal_Name_-_Last_Name>
<wd:Legal_Name_is_Preferred_Name>1</wd:Legal_Name_is_Preferred_Name>
<wd:Preferred_Name_in_General_Display_Format>Luke Skywalker</wd:Preferred_Name_in_General_Display_Format>
<wd:Preferred_Name_-_First_Name>Luke</wd:Preferred_Name_-_First_Name>
<wd:Preferred_Name_-_Last_Name>Skywalker</wd:Preferred_Name_-_Last_Name>
<wd:Hire_Date>2019-07-01-07:00</wd:Hire_Date>
<wd:Original_Hire_Date>2019-07-01-07:00</wd:Original_Hire_Date>
<wd:Job_Title_-_Current>Contractor</wd:Job_Title_-_Current>
<wd:Position_Object>
<wd:Current_Position_Filled_-_Effective_Date>2019-07-01-07:00</wd:Current_Position_Filled_-_Effective_Date>
</wd:Position_Object>
<wd:Email_-_Work wd:Descriptor="luke@whiting.com">
<wd:ID wd:type="WID">106d0dc1e3f2017c123580628801d001</wd:ID>
</wd:Email_-_Work>
<wd:location wd:Descriptor="Mytown">
<wd:ID wd:type="WID">d34191b0c905106f759d0975538e88c8</wd:ID>
<wd:ID wd:type="Location_ID">LOC008-Myto</wd:ID>
</wd:location>
<wd:location_Object>
<wd:Primary_Address_-_Line_1>701 4th Avenue NW</wd:Primary_Address_-_Line_1>
<wd:Primary_Address_-_Line_2>PO Box 123</wd:Primary_Address_-_Line_2>
<wd:Primary_Address_-_Line_3>Mytown, ND 12345</wd:Primary_Address_-_Line_3>
<wd:city>Mytown</wd:city>
<wd:state>North Dakota</wd:state>
<wd:Primary_Address_-_Postal_Code>12345</wd:Primary_Address_-_Postal_Code>
</wd:location_Object>
<wd:Cost_Center_-_Name>Field Operations</wd:Cost_Center_-_Name>
<wd:WOG_EE_Driver_Eligibility>0</wd:WOG_EE_Driver_Eligibility>
<wd:Legal_Name_in_General_Display_Format>Luke Skywater</wd:Legal_Name_in_General_Display_Format>
<wd:Cost_Center_-_ID>1010</wd:Cost_Center_-_ID>
<wd:Worker_Status>Active</wd:Worker_Status>
<wd:Location_Address_-_Region__Any_Country_ wd:Descriptor="North Dakota">
<wd:ID wd:type="WID">0567a9c4e90340e192aa655d387323c6</wd:ID>
<wd:ID wd:type="Country_Region_ID">USA-ND</wd:ID>
<wd:ID wd:type="ISO_3166-2_Code">ND</wd:ID>
</wd:Location_Address_-_Region__Any_Country_>
<wd:Job_Code>CONTRACT</wd:Job_Code>
<wd:Exempt>0</wd:Exempt>
<wd:User_Name>lskywalker</wd:User_Name>
<wd:Worker_is_Contingent_Worker>1</wd:Worker_is_Contingent_Worker>
<wd:Contract_End_Date>2019-08-07-07:00</wd:Contract_End_Date>
<wd:Cost_Center_Hierarchy wd:Descriptor="Operations">
<wd:ID wd:type="WID">d9a3758225e01071585ef203864f2bfa</wd:ID>
<wd:ID wd:type="Organization_Reference_ID">Operations</wd:ID>
<wd:ID wd:type="Custom_Organization_Reference_ID">Operations</wd:ID>
</wd:Cost_Center_Hierarchy>
<wd:Region wd:Descriptor="Northern Rockies">
<wd:ID wd:type="WID">d9a3758225e010715924f5d0bd472cde</wd:ID>
<wd:ID wd:type="Organization_Reference_ID">Northern Rockies</wd:ID>
<wd:ID wd:type="Region_Reference_ID">Northern Rockies</wd:ID>
</wd:Region>
</wd:Report_Entry>
</wd:report_data>
</env:Body>
</env:Envelope>