Need a suggestion on Java Web Service(SOAP) Message format. Thinking of two message formats.
Could you please share your thoughts on these approaches. What would you recommend?
1) Specific Message Format Specifying the message nodes with the actual names of the data attributes like User first name , last name, ssn .... etc. see the sample below
Pros: Message xsd will have the actual data types for the data to be propagated. This ensures the data is valid.
Cons: Changes to the message format will lead to the xsd change which in turn lead to multiple versions of the service. this would cost the maintenance of the different versions of the service.
2) Generic Message Format Specifying the message nodes with the name value pairs. See the example message below.
Pros: Additional data can be sent with additional properties wihtout changing the message format. Single version of the message can be maintained easily.
Cons: Data is not typed and can not be validated. Service implementation needs to hard code the property names, parse the data, validate the data. Handling data with multiple values would be with some separator like comma(,). Handling the formatted data for the dates, time, currency data ... etc would be expensive.
Specific Format Message
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:myTestServiceOperation xmlns:ns1="http://xmlns.myenterprise.com/myenterprise/myTestWebService/types/">
<UserInfo>
<BioData>
<FirstName>John</FirstName>
<LastName>Smith</LastName>
<SSN>123-34-567</PersonNumber>
<DateOfBirth>09/01/1980</DataOfBirth>
</BioData>
<EducationalInfo>
<Qualification>Master of Science</Qualification>
<Institute>ABC</Institure>
<CourseDuration>2 Years</CourseDuration>
</EducationalInfo>
<EmploymentInfo>
<JobTile>Administrator</JobTitle>
<Employer>XYZ Corp</Employer>
<EmploymentInfo>
</UserInfo>
</ns1:myTestServiceOperation>
</soap:Body>
</soap:Envelope>
Generic Format Message
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:myTestServiceOperation xmlns:ns1="http://xmlns.myenterprise.com/myenterprise/myTestWebService/types/">
<Record category="BioData">
<Property name="FirstName" value="John"/>
<Property name="LastName" value="Smith"/>
<Property name="SSN" value="123-34-567"/>
</Record>
<Record category="Education">
<Property name="Qualification" value="Master of Science"/>
<Property name="Institute" value="ABC"/>
<Property name="CourseDuration" value="2 Years"/>
</Record>
<Record category="Employment">
<Property name="JobTile" value="Manager"/>
<Property name="XYZ Corp" value="XYZ Corp"/>
<Property name="CourseDuration" value="2 Years"/>
</Record>
</ns1:myTestServiceOperation>
</soap:Body>
</soap:Envelope>