1

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

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

2 Answers 2

0

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

1
  • 2
    Don't use wsHttpBinding for backward compatibility with ASMX clients. Jan 17, 2011 at 22:28
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.