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

后端 未结 2 1648
粉色の甜心
粉色の甜心 2020-12-22 10:30

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

相关标签:
2条回答
  • 2020-12-22 11:08

    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

    0 讨论(0)
  • 2020-12-22 11:19

    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 讨论(0)
提交回复
热议问题