开发者

WCF (svc) Service but client wants to connect as if it was ".asmx"

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, c开发者_JAVA技巧lient says

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

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?

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.

Tony


It is completely do-able. Just use an endpoint that exposes the service using basicHttpBinding or wsHttpBinding. The "file extension" of the URL doesn't make any difference to the client, only the content of the rerquest/response.

Here's a reference to another SO question: REST / SOAP endpoints for a WCF service


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

  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

  5. Some changes is code as shown below-

  6. In web.config in Tag add following code

      <system.web>
       <webServices>
         <conformanceWarnings>
           <remove name='BasicProfile1_1'/>
         </conformanceWarnings>
       </webServices>
      </system.web>
    
  7. Add following 2 attribute on interface(on servicecontract of WCF)

     [WebService(Name = "Service1")]
     [WebServiceBinding(Name = "Service1", ConformsTo =   WsiProfiles.BasicProfile1_1, EmitConformanceClaims = true)]
    
  8. Add [WebMethod] attribute on each operation contract.

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

your service can now be consumed by asmx client too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜