Hi,
I am designing a WCF service which a client will call to get a list of GUID's from a server.
How should I define my endpoint contract?
Should I just return an Array?
If so, will the array just be serialized by WCF?
Hi,
I am designing a WCF service which a client will call to get a list of GUID's from a server.
How should I define my endpoint contract?
Should I just return an Array?
If so, will the array just be serialized by WCF?
The Guids, if you're going for SOA oriented services, will need to be set as strings. The client will be responsible for turning them back into whatever. As for the listing of the Guids, they'd be returned as an array. If you have a contract with a regular Generics List Object of Guids like this
[DataMember] List<Guid> SomeGuidsGoInHere {get;set;}
then you'll get an array of Guids back. Which could cause compatability issues. What you'll want to do is setup a List of strings like this.
[DataMember] List<String> SomeGuidsAsStringsGoInHere {get;set;}
If the client app has enough stuff to call web services, why not create the UUIDs locally using a built-in API?
When developing in Visual Studio, Microsoft provides some specialized magic when generating the WSDL for a method that takes a Guid as a parameter or returns a Guid; it imposes a restriction on the Guid.
You can just return a Guid to your heart's content, both in WCF and in regular web services.
Guid Simple Type is below:
<s:simpleType name="guid">
<s:restriction base="s:string">
<s:pattern value="[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" />
</s:restriction>
</s:simpleType>
And generated WSDL for a method that takes a Guid as a parameter:
<s:element name="GetToken">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="objUserGUID" type="s1:guid" />
<s:element minOccurs="0" maxOccurs="1" name="strPassword" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>