Click here to Skip to main content
15,918,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The Microsoft enterprise device management protocol for Windows Phone 8 document tells to "Implement discovery web service. The service is a restful web service over HTTPS (server authentication only)”.

I have similar query in the MSDN forum too:
http://social.msdn.microsoft.com/Forums/en-US/770651a1-6345-41d8-980e-856f2cc108eb/wcf-how-to-choose-the-right-binding-and-contracts-when-the-request-and-response-data-is-given[^]

If I implement REST service I have trouble in getting request and response data as soap xml. If I use soap based binding I have trouble in making GET request. Also I can't have multiple bindings with different address, this breaks the protocol uri defined by MSFT.

I new to WCF and have trouble in implementing my right WCF Service so that it can be called from Microsoft Phone 8 enrollment client.

Also I could not find any link which talks about implementing WCF service based on such webservice request and response data.

Please can you suggest me how does the contracts should look and what kind binding do I need to use achieve below HTTP GET and HTTP POST request and response.

Below are the request and response of the web service defined by Microsoft.


HTTP GET

Request:
Request Full Url: http://EnterpriseEnrollment.ds.test.com/EnrollmentServer/Discovery.svc
Content Type: unknown
Header Byte Count: 153
Body Byte Count:0

Header:
GET /EnrollmentServer/Discovery.svc HTTP/1.1
User-Agent: WIndows Phone 8 Enrollment Client
Host: EnterpriseEnrollment.ds.test.com
Pragma: no-cache


Response:
Request Full Url: http://EnterpriseEnrollment.ds.test.com/EnrollmentServer/Discovery.svc
Content Type: text/html
Header Byte Count: 248
Body Byte Count: 0

Header:
HTTP/1.1 200 OK
Connection: Keep-Alive
Pragma: no-cache
Cache-Control: no-cache
Content-Type: text/html
Content-Length: 0


HTTP POST

Request:
Header:
POST /EnrollmentServer/Discovery.svc HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8
User-Agent: Windows Phone 8 Enrollment Client
Host: EnterpriseEnrollment.ds.test.com
Content-Length: xxx
Cache-Control: no-cache

XML
<?xml version="1.0"?>
<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Header>
<a:Action s:mustUnderstand="1">ttp://schemas.microsoft.com/windows/management/2012/01/enrollment/IDiscoveryService/Discover</a:Action>
<a:MessageID>urn:uuid: 748132ec-a575-4329-b01b-6171a9cf8478</a:MessageID>
<a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo><a:To s:mustUnderstand="1">https:// EnterpriseEnrollment.ds.test.com/EnrollmentServer/Discovery.svc</a:To>
</s:Header>
<s:Body>
<Discover xmlns="http://schemas.microsoft.com/windows/management/2012/01/enrollment/">
<request xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<EmailAddress>user@ds.test.com</EmailAddress>
<RequestVersion>1.0</RequestVersion>
</request>
</Discover>
</s:Body>
</s:Envelope>



Response:
Header
HTTP/1.1 200 OK
Content-Length: 865
Content-Type: application/soap+xml; charset=utf-8
Server: EnterpriseEnrollment.ds.mot.com
Date: Tue, 02 Aug 2012 00:32:56 GMT


XML
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://schemas.microsoft.com/windows/management/2012/01/enrollment/IDiscoveryService/DiscoverResponse</a:Action>
<ActivityId>d9eb2fdd-e38a-46ee-bd93-aea9dc86a3b8</ActivityId>
<a:RelatesTo>urn:uuid: 748132ec-a575-4329-b01b-6171a9cf8478</a:RelatesTo>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><DiscoverResponse xmlns="http://schemas.microsoft.com/windows/management/2012/01/enrollment">
<DiscoverResult>
<AuthPolicy>OnPremise</AuthPolicy>
<EnrollmentPolicyServiceUrl>https:// EnterpriseEnrollment.ds.test.com/ENROLLMENTSERVER/DEVICEENROLLMENTWEBSERVICE.SVC</EnrollmentPolicyServiceUrl>
<EnrollmentServiceUrl>https:// EnterpriseEnrollment.ds.test.com/ENROLLMENTSERVER/DEVICEENROLLMENTWEBSERVICE.SVC</EnrollmentServiceUrl>
</DiscoverResult>
</DiscoverResponse>
</s:Body>
</s:Envelope>



Currently my service contract looks as below:
C#
[ServiceContract(Namespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment/")]
[XmlSerializerFormat]
public interface IDiscoveryService
{
[OperationContract]
[WebGet(UriTemplate = "")]
string GetRequest();
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)]
Result Discover(Request request);   //Where Result and Request are DataContracts
}


Thanks,
Posted
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900