I am creating a web service to receive data from another source which will have the following format when the request is made.
The SOAP request for the call has been provided (see below) so I need to accept the data in this format. It is also going into an existing set of web services which can not be updated at this time. They are written in C# using the older style WSDL Web Service.
<?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>
<GetDepartmentData xmlns="webservice.localhost/">
<ID>123</ID>
<Name>John Smith</Name>
<Departments>
<DepartmentID>1</DepartmentID>
<DepartmentID>2</DepartmentID>
<DepartmentID>4</DepartmentID>
</Departments>
<Phone>0123456789</Phone>
</GetDepartmentData>
</soap:Body>
</soap:Envelope>
I need to take this request then extract all the data and send into a SQL stored procedure for processing.
Everything is pretty straight forward apart from the 'Departments' section as I am unsure of the correct data type to use and how best to handle this as all the other web service just have single non-complex data types.
The code for the method is as follows:
[WebMethod]
public string GetDepartmentData(int ID, string Name, ???? Departments, string Phone)
{
// Do something with the input here
}
My plan is to convert the Departments into either a XML data type which I can send into SQL and then split into a table or create a delimited string from the DepartmentID values and then split that in SQL. Not sure yet but that will be the easier part.
The problem I am having is I am unsure of the best way to create the method to handle the SOAP request I am being sent.
Thanks.