Consume WCF service from .Net 1.1

Written by stevey on January 2nd, 2011

I have struggled for the past week not being able to consume a ASMX service exposed through a WCF service app that was created on .Net 4.0 and Entity Framework. The key to make a WCF service consumable by legacy .Net app was to expose the service as an old fashion ASMX, through adding a XmlSerializerFormat attribute while building the ServiceContract interface, as shown in this sample:

[ServiceContract, XmlSerializerFormat]

public interface IService1

{

[OperationContract]

string GetData(int value);

 

[OperationContract]

CompositeType GetDataUsingDataContract(CompositeType composite);

 

}

 

The second key step was to make sure the web.config of the WCF service project would use “basicHttpBinding” and set endpoint address to “basic” type. When I first started out, many cited the reference from MSDN at http://msdn.microsoft.com/en-us/library/ms751433.aspx; I followed the example, and still got the “Underneath connection had been closed” error. Today, I came across another posting at http://social.msdn.microsoft.com/forums/en-US/wcf/thread/1f8c7fe9-784c-4beb-8d0f-060bf8bfc24f and that had liberated me from wondering why this damn thing not working – well, the web.config example in the MSDN article had an empty string in the address field while this social.msdn positing had a “basic” in the enpoint address;  I tried that and it worked this time! Thanks Jay R. Wren who answered a user’s question at social.msdn.com.

 

Here was the endpoint configuration that worked on my case:

<service name=”WcfService1.Service1″  behaviorConfiguration=”AsmxBehavior”>

<endpoint address=”basic” binding=”basicHttpBinding” contract=”WcfService1.IService1″></endpoint>

 

The entire web.config file that is in the WCF app project that will generate the ASMX service to be consumed by .Net 1.1 client is as below:

<?xml version=”1.0″?>

<configuration>

<system.web>

<compilation debug=”true” targetFramework=”4.0″ />

</system.web>

<system.serviceModel>

<services>

<service name=”WcfService1.Service1″  behaviorConfiguration=”AsmxBehavior”>

<endpoint address=”basic” binding=”basicHttpBinding” contract=”WcfService1.IService1″></endpoint>

</service>

</services>

<behaviors>

<serviceBehaviors>

<behavior name=”AsmxBehavior”>

<!– To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment –>

<serviceMetadata httpGetEnabled=”true”/>

<!– To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information –>

<serviceDebug includeExceptionDetailInFaults=”false”/>

</behavior>

</serviceBehaviors>

</behaviors>

<serviceHostingEnvironment multipleSiteBindingsEnabled=”true” />

</system.serviceModel>

<system.webServer>

<modules runAllManagedModulesForAllRequests=”true”/>

</system.webServer>

 

</configuration>

 

 

2 Comments so far ↓

  1. Thank you for sharing. Not to many people in your position are so gracious. Your article was very poignant and understandable. It helped me to understand very clearly. Thank you for your help.
    My website is about Wedding planner.

  2. I’m having a tiny problem I can’t seem to be able to subscribe your feed, I’m using google reader by the way.
    My website is on Home fitness.

Leave a Comment