62,263
社区成员
发帖
与我相关
我的任务
分享
契约
[ServiceContract]
[XmlSerializerFormat]
public interface ILog
{
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
List<LoginResponseBDU> Login(string userid, string password);
}
实现
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Log : ILog
{
public List<LoginResponseBDU> Login(string userid, string password)
{
LoginDAL loginDAL = new LoginDAL();
List<LoginResponseBDU> ResponseList = new List<LoginResponseBDU>();
int status = loginDAL.Login(userid, password, out ResponseList);
return ResponseList;
}
}
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="wcftest.Log">
<endpoint address="wcftest" kind="webHttpEndpoint" contract="wcftest.ILog" binding="webHttpBinding" bindingConfiguration="webHttpbinding"/>
</service>
</services>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint crossDomainScriptAccessEnabled="True"/>
</webHttpEndpoint>
</standardEndpoints>
<bindings>
<webHttpBinding>
<binding name="webHttpbinding" crossDomainScriptAccessEnabled="true" />
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点
<serviceMetadata httpGetEnabled="true"/>
要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
$.ajax({
type: "GET",
url: "http://172.168.1.10:1993/Service1.svc/wcftest/Login",
dataType: "xml",
contentType: "json",
data: { "userid": 'mary', "password": '12345' },
success: function (xml) {
$(xml).find('LoginResponseBDU').each(function () {
$strUser = $(this);
User = $strUser.find("autobusiness").text();
})
var detailUrl = "detail.html?id=" + User;
var html = "<tr><td>";
html += User + "</td><td>";
html += "<a href='" + detailUrl + "'>" + User + "</a></td><td>";
html += User + "</td><td>";
html += User + "</td></tr>";
$("#employees").append(html);
// });
$("#employees tr:odd").addClass("oddRow");
}
});