我有一个WCF服务,我想将它作为RESTfull服务和SOAP服务公开.以前有人做过这样的事吗?
WebAPI是否支持SOAP?我正在尝试在MVC4中编写SOAP服务器,虽然我可以在WCF中执行它,但似乎WebAPI正在替换它,但我认为没有办法在此使用SOAP,只使用REST Style接口的JSON/XML.
我有一个通过我的ASPX站点公开的WCF服务库,如下所示
[System.ServiceModel.OperationContract]
[System.ServiceModel.Web.WebInvoke(
Method= "POST",
RequestFormat=System.ServiceModel.Web. WebMessageFormat .Json,
ResponseFormat=System.ServiceModel.Web.WebMessageFormat .Json)]
LogonResponse Logon(LogonRequest logonRequest);
[System.Runtime.Serialization.DataContract]
[ Serializable()]
public class LogonRequest
{
[System.Runtime.Serialization.DataMember]
public string EMailAddress;
[System.Runtime.Serialization.DataMember]
public string Password;
}
Run Code Online (Sandbox Code Playgroud)
在我的测试页面中,我可以通过MS Ajax调用: -
<asp:ScriptManager ID ="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/testService.svc" />
</Services>
</asp:ScriptManager>
.
.
.
function clsLogonRequest(eMailAddress, password) {
this .EMailAddress = eMailAddress;
this .Password = password;
}
function login(eMailAddress, password) {
var LogonRequest = new clsLogonRequest(eMailAddress, password);
name.API.IAPI.Logon(LogonRequest, onSuccess, onFailure);
}
function onSuccess(result) {
$( "#txtSessionId").val(result.SessionId);
$( "#txtUserName").val(result.Name);
$( …Run Code Online (Sandbox Code Playgroud)