WCF(svc)服务,但是客户端希望像".asmx"一样进行连接. [英] WCF (svc) Service but client wants to connect as if it was ".asmx"

查看:337
本文介绍了WCF(svc)服务,但是客户端希望像".asmx"一样进行连接.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这种情况.客户要求我们提供一个WebService.我创建了WCF服务.在将其发送给Web服务描述的URL后,客户端会说

I have this scenario. Client requested us to have a WebService. I created a WCF Service. After we sent them our url to the web service description, client says

就这样,我们不能使用WCF 服务,您可以将其发布到网络上吗 服务吗?

As it is we cannot consume a WCF service, can you publish it a web service?

现在我想知道,他们在问我一个asmx ...对吗? 有什么方法可以提供"我的WCF服务作为asmx服务,这样我就不必重写整个东西了?

Now i am wondering, they are asking me for a asmx... right? Is there any way that i can "offer" my WCF service as an asmx service so i don't have to rewrite the whole thing?

我的第一个解决方案"是拥有一个.asmx文件,直接调用我的.svc文件...我不知道.我还没有尝试过,但是我正在朝那个方向前进.

my first "solution" is to have an .asmx file calling my .svc files directly... i don't know. I havent tried but i am heading on that direction.

任何想法都将受到高度赞赏.

Any ideas would be highly appreciated.

托尼

推荐答案

很有可能.按照下面提到的步骤进行操作,您就可以将WCF服务公开为ASMX终结点.

It's very much possible.Follow the steps mentioned below and you'll be able to expose WCF service as ASMX endpoint.

  1. 添加新的Web服务文件(.asmx)
  2. 现在打开Web .asmx文件的节点并删除.asmx.cs文件
  3. 一旦.cs文件被删除.您会找到wcfasasmx.asmx文件.
  4. 我有WCF类名称,称为Service1(来自基本WCF服务),并且该类存在于当前的NameSpace中.所以我将类名更改为mynamespace.Service1

  1. Add new web service file (.asmx)
  2. Now open the node of web .asmx file and delete .asmx.cs file
  3. Once .cs file is deleted. You will find wcfasasmx.asmx file.
  4. I have WCF class name as Service1(from the basic WCF service) and this class is present in current NameSpace. So I changed class name as mynamespace.Service1

某些更改是如下所示的代码-

Some changes is code as shown below-

在Tag的web.config中添加以下代码

In web.config in Tag add following code

  <system.web>
   <webServices>
     <conformanceWarnings>
       <remove name='BasicProfile1_1'/>
     </conformanceWarnings>
   </webServices>
  </system.web>

  • 在界面上(在WCF的 servicecontract 上)添加以下2个属性

  • Add following 2 attribute on interface(on servicecontract of WCF)

     [WebService(Name = "Service1")]
     [WebServiceBinding(Name = "Service1", ConformsTo =   WsiProfiles.BasicProfile1_1, EmitConformanceClaims = true)]
    

  • 在每个操作合同上添加[WebMethod]属性.

  • Add [WebMethod] attribute on each operation contract.

    [OperationContract]
    [WebMethod] 
    string GetData(int value);
    

  • 您的服务现在也可以由asmx客户端使用.

    your service can now be consumed by asmx client too.

    这篇关于WCF(svc)服务,但是客户端希望像".asmx"一样进行连接.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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