• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1966
  • Last Modified:

web exception when calling an .asmx webs service from within a wcf service

I have a local wcf web service in my website that calls an asmx sesrvice from another website (this site exists on the same server).

When my website calls my local service it receives a web exception. A 400 bad request message. The stack trace points to the call to the .asmx webmethod. I have tried calling my wcf service from a local win forms app and I receive a protocol exception : The remote server returned an unexpected response: (405) Method Not Allowed.

I have tried adding a clientaccesspolicy.xml file to both sites root folders with no success.

The website also has a restful json wcf service that does not call another service that runs just fine.
  • 5
  • 5
1 Solution
how the service, web service hosted ? their uRLS...how you are accessing them ?
Rikus_TrentAuthor Commented:
The wcf services are hosted as part of the website in IIS6.  http://mysite/services/service1.svc

The asmx service is at a different site. In the website project I've added a web reference to it, and then used the proxy class within the svc service.

The website uses the microsoft ajax library to call the svc service from the client as seen in the code window below.

I currently have the whole thing running successfully on a test server calling the asmx service from the same production location. The only difference I can see between my test and production environment is that the production has each site in its own root folder, where my test has all the sites as virtual folders under the default website.
        minimumPrefixLength: 1,
        serviceMethod: 'GetStations',
        servicePath: 'services/UIControlPopulation.svc',
        enableCaching: true,
        completionSetCount: 10,
        completionInterval: 250

Open in new window

Rikus_TrentAuthor Commented:
Issue update:

I have change from using a WEB REFERENCE in the wcf service to adding the asmx service as a SERVICE REFERENCE and using that in the wcf service.

I am now receiving a EndpointNotFoundError: There was no endpoint listening at http://mySite/theService.asmx that could accept the message.

I have browsed to this address in a browser without issue. And still it works from my test server, but not my production server.
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

please paste complete error and can we see ur endpoint configuration and how you are invoking your service please ?
Rikus_TrentAuthor Commented:
Here's the error information:

Exception Type:

There was no endpoint listening at http://mySite/theService.asmx that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.


Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at AirportInfoService.AirportInfoSoap.GetAirports(GetAirportsRequest request)
at AirportInfoService.AirportInfoSoapClient.AirportInfoService.AirportInfoSoap.GetAirports(GetAirportsRequest request)
at AirportInfoService.AirportInfoSoapClient.GetAirports()
at UIControlPopulation.GetStations(String prefixText, Int32 count)
at SyncInvokeGetStations(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

InnerException: System.Net.WebException
InnerException Message: The remote server returned an error: (400) Bad Request.

    <binding name="AirportInfoSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
     receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
     bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
     maxBufferSize="32768000" maxBufferPoolSize="524288" maxReceivedMessageSize="32768000"
     messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
      maxBytesPerRead="4096" maxNameTableCharCount="16384" />
     <security mode="None">
      <transport clientCredentialType="None" proxyCredentialType="None"
       realm="" />
      <message clientCredentialType="UserName" algorithmSuite="Default" />
   <endpoint address="http://mySite/theService.asmx"
    binding="basicHttpBinding" bindingConfiguration="AirportInfoSoap"
    contract="AirportInfoService.AirportInfoSoap" name="AirportInfoSoap" />
            <behavior name="SOAPBehavior">
            <behavior name="UIControlPopulationBehavior">
                  <serviceMetadata httpGetEnabled="true"/>
                  <serviceDebug includeExceptionDetailInFaults="false"/>
      <service behaviorConfiguration="UIControlPopulationBehavior" name="UIControlPopulation">
            <endpoint address="" binding="webHttpBinding" contract="IUIControlPopulation" behaviorConfiguration="SOAPBehavior"/>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

I am using the VS2008 generated client objects for the asmx service within the wcf service:

AirportInfoService.AirportInfoSoapClient airportInfoClient = new AirportInfoService.AirportInfoSoapClient();
_stations = new List<AirportInfoService.Airport>(airportInfoClient.GetAirports());

I am calling the WCF service from the clientside control as mentioned above.
The endpoint address "http://mySite/theService.asmx" has web methods or "Operation contracts" ?

Looks like your giving .asmx instead of .svc URL in the config.
Rikus_TrentAuthor Commented:
That's correct. The client endpoint is pointing to an asmx web service (Web Methods). The local scv service is calling the asmx service.

We have several asmx web services deployed using either web references or service references depending on the project and all function correctly. I have tried using both a service reference and a web reference for this asmx service with similar results (works on my test server, but not production). The service reference  gives me the above error and the web reference only gives me a 400 bad request message with no other info.
The above configuration contains for both server and client configurations? have you merged it or is it only for client or server ?

Can you also give the separate configurations for the service in server and on client please ?
Rikus_TrentAuthor Commented:
Thats it for the service configuration... It has the server configurations for .svc service (UIControlPopulation) which acts as a client of the asmx service (AirportInfoSoap).

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now