转换WCF SOAP服务图书馆REST服务库MVC [英] Converting WCF SOAP Service Library to REST Service library for MVC

查看:123
本文介绍了转换WCF SOAP服务图书馆REST服务库MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题陈述:

我们已经使用WCF服务库构建MVC 4应用程序的(SVC的文件中未WCF服务应用程序)。所有我们正在通过WCF SOAP服务library.Everything做MVC的CRUD操作的工作fine.Now客户突然改变了要求,要求我们WCF SOAP转换为REST。

We have built MVC 4 application using WCF Service library (not WCF Service Application with svc file). All of the MVC CRUD operations we are doing through WCF SOAP Service library.Everything is working fine.Now suddenly client has changed requirement and asking us to convert WCF SOAP to REST.

我经历了许多的URL去转换WCF SOAP来REST.In所有URL的,他们都提到转换WCF SOAP服务应用WCF REST不是WCF SOAP服务库WCF REST。

I went through many URL's for converting WCF SOAP to REST.In all the URL's they have mentioned converting WCF SOAP Service Application to WCF REST not the WCF SOAP Service library to WCF REST.

我的问题是,我们可以转换WCF服务库SOAP来REST.??Is转换是相同的两个WCF服务库和WCF服务Application.??If可能它影响太多,改变现有code ??

这将是巨大的,如果任何人都可以提出WCF SOAP某些URL的解释,并转换为REST MVC中的更好的方法。

It would be great if anyone can suggest the better way of converting WCF SOAP to REST in MVC with some URL's and explanation.

推荐答案

如果不知道它可以帮助,但我已经做了这暴露于SOAP和REST同时WCF库。 REST暴露XML / JSON和返回类型取决于输入请求。
它可以通过配置文件进行配置,煤矿是这样的:

Not sure if it helps, but i have done WCF library which is exposed to Soap and REST at the same time. REST exposes XML/JSON and return type depends on input request. It can be configured via config file, mine looked like this:

<behaviors>
  <serviceBehaviors>
    <behavior name="BehaviourService">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="BehaviourEndPoint"></behavior>
      <behavior name="BehaviourWebHttp">
        <webHttp defaultBodyStyle="Wrapped" faultExceptionEnabled="True" automaticFormatSelectionEnabled="True"/>
      </behavior>
  </endpointBehaviors>

</behaviors>
<services>
  <service name="NameSpace.MyClass" behaviorConfiguration="BehaviourService" >
    <!--SoapUI-->
    <endpoint name="Name" address ="soap" binding="basicHttpBinding" contract="NameSpace.IMyClass"></endpoint>
    <!--Rest-->
    <endpoint name="Name" address="" binding="webHttpBinding" behaviorConfiguration="BehaviourWebHttp" contract="NameSpace.IMyClass" ></endpoint>
    <!--MEX-->
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:89/MyAddress"/>
      </baseAddresses>
    </host>
  </service>
</services>

和类似的服务:

[ServiceContract(Namespace = "http://www.mycompany.com", Name = "MyName")]
[DataContractFormat]
public interface IMyClass
{
    [OperationContract]
    [WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "MyMethod", Method = "POST")]
    bool MyMethod();
}

这篇关于转换WCF SOAP服务图书馆REST服务库MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆