How to convert WCF service to REST using Dynamic Response
I have invoked a WSDL service from Java using a WEB REFERENCE named "eps". Now I have created a WCF service with this "Webreference" and the Response is in "XML" form and the response will be dynamic each time. Everything works well, now I have to call the Windows Phone 8.1 WCF service with REST endpoints. I am done with the "web.config" file. My problem is "How does the service get parameters?"
see my code below:
[DataContract]
public string login(string uname, string pwd)
{
XDocument doc = XDocument.Parse(eps.m12345(uname,pwd));
string connection = Convert.ToString(doc);
return connection;
}
How to allow the client to enter "Username" and "Password". This is the main problem.
Here is my OperationContract:
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "live_login?uname={uname}&pwd={pwd}")]
string login(string uname, string pwd);
In this case, it works for a static response:
[DataContract]
public string login()
{
return "ABC";
}
[OperationContract]
[WebInvoke(Method = "GET",UriTemplate = "login")]
This code I was calling on Windows Phone 8.1
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost:xxxx/xxxxxxxxx.svc/login");
HttpResponseMessage response = await client.SendAsync(request);
string data = await response.Content.ReadAsStringAsync();
var dialog = new MessageDialog(data);
await dialog.ShowAsync();
+3
source to share
No one has answered this question yet
Check out similar questions: