我使用名为“eps”的WEB REFERENCE从Java调用了WSDL服务。 现在我用“Webreference”创建了WCF服务,Response以“XML”的形式创建, 每次响应都是动态的。 一切正常,现在我必须使用REST端点将WCF服务调用到Windows Phone 8.1。 我完成了“web.config”文件,我的问题是 “服务如何获取参数?”
请参阅下面的代码:
[DataContract]
public string login(string uname, string pwd)
{
XDocument doc = XDocument.Parse(eps.m12345(uname,pwd));
string connection = Convert.ToString(doc);
return connection;
}
如何启用允许客户输入“用户名”和“密码”。这是主要问题。
这是我的OperationContract:
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "live_login?uname={uname}&pwd={pwd}")]
string login(string uname, string pwd);
在这种情况下,它适用于静态响应:
[DataContract]
public string login()
{
return "ABC";
}
[OperationContract]
[WebInvoke(Method = "GET",UriTemplate = "login")]
以下代码我在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();