Alex
Alex

Reputation: 770

Custom data type as parameter in WebService

I'm writing a WebService in .NET and use a custom type with no public properties. It looks like this: Class diagramm for MacAddress

It is similar to the built-in type Guid but with special validation rules for MAC addresses. The SOAP description looks like this:

<StringProperty>string</StringProperty>
<GuidProperty>guid</GuidProperty>
<MacAddressProperty />
<!--My aim: <MacAddressProperty>macaddress</MacAddressProperty> -->

My question: Can I create a type like MacAddress to ensure type-safety and use it as parameter for a WebService? How can I say that the delivered string from the caller should be filled in the parameterized constructor (probably like Guid works - it has a constructor with a string-parameter)?

Thanks Alex

Upvotes: 0

Views: 2217

Answers (1)

dutertimes
dutertimes

Reputation: 137

If you use properties values in your struct and parametrized it as vieweable by the web service. Your property will be filled/serialized prior sendind it to the client.

See this tutorial, maybe it will help understand the mechanics.

http://www.codeproject.com/KB/WCF/first_WCF_Service.aspx

Upvotes: 1

Related Questions