Search code examples
c#xmlweb-servicesasmx

How do i create a webservice that recieves XML?


I need to build a web service that accepts XML data.

The XML will send as the below example :

<Person>
<LegalName>
  <FirstName>Ralph</FirstName>
  <LastName>Anderson</LastName>
  <PhoneticFirstName>rah-lf</PhoneticFirstName>
</LegalName>
<SSN>122-34-1232</SSN>
<Demographics>
  <Sex>male</Sex>
  <Height>502</Height>
</Demographics>
<DriversLicense>
  <DriversLicenseNumber>1234</DriversLicenseNumber>
  <IssuingState>CA</IssuingState>
</DriversLicense>

My understanding is I need to write something like this:

public Service () {

    [WebMethod]
    public void CreateRecord(XmlDocument newRecord)
    {
        // do stuff
    }
}

How I can do that?


Solution

  • You could try to understand how it works and find a nice artical here: https://msdn.microsoft.com/en-us/library/hh534080.aspx