WCF clients to connect to ASP.NET Web services

40 views Asked by At

I have a project with ASMX Webservice and a desktop client connecting to it using Client proxy (which use WSDL from ASM webservice).

Upgraded one the proxy using svc utility to produce WCF service (from ASMX services).

Note that Client is now WCF but the server is ASMX.

This Microsoft link says that WCF clients can connect to ASP.NET Web services. https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/adopting-wcf?redirectedfrom=MSDN

The above link says "WCF clients can use ASP.NET Web services". But getting the below error from the client when WCF client tries to access the ASP.NET webservices(which is ASMX). How to get this scenario "WCF clients can use ASP.NET Web services" working?

An exception of type 'System.Web.Services.Protocols.SoapHeaderException' occurred in System.Web.Services.dll but was not handled in user code
Additional information: Microsoft.Web.Services3.Security.SecurityFault: Header http://schemas.xmlsoap.org/ws/2004/08/addressing:Action for ultimate recipient is required but not present in the message.
   at Microsoft.Web.Services3.Design.RequireSoapHeaderAssertion.RequireSoapHeaderFilter.ProcessMessage(SoapEnvelope envelope)
   at Microsoft.Web.Services3.Pipeline.ProcessInputMessage(SoapEnvelope envelope)
   at Microsoft.Web.Services3.WseProtocol.FilterRequest(SoapEnvelope requestEnvelope)
   at Microsoft.Web.Services3.WseProtocol.RouteRequest(SoapServerMessage message)
   at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
   at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
1

There are 1 answers

1
QI You On

The System.Web.Services.Protocols.SoapHeaderException issue is usually due to the MustUnderstand=true of the SOAP header.

You can set up your code like this when you call a service:

MyWebService ws = new MyWebService();

    try {
        MyHeader customHeader = new MyHeader();
        customHeader.MustUnderstand = false;
        ws.myHeader = customHeader;
    
    }
    catch (Exception e) {
        Console.WriteLine ("Exception: {0}", e.ToString());
    }