Link to home
Start Free TrialLog in
Avatar of Rikus_Trent
Rikus_TrentFlag for United States of America

asked on

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.
Avatar of Aaron Jabamani
Aaron Jabamani
Flag of United Kingdom of Great Britain and Northern Ireland image

how the service, web service hosted ? their uRLS...how you are accessing them ?
Avatar of Rikus_Trent

ASKER

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.
$('#ReportStation').autoComplete({
        minimumPrefixLength: 1,
        serviceMethod: 'GetStations',
        servicePath: 'services/UIControlPopulation.svc',
        enableCaching: true,
        completionSetCount: 10,
        completionInterval: 250
    });

Open in new window

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.
please paste complete error and can we see ur endpoint configuration and how you are invoking your service please ?
Here's the error information:

Exception Type:
System.ServiceModel.EndpointNotFoundException

Mesasge:
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.

StackTrace:

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.


Configuration:
<system.serviceModel>
            <bindings>
   <basicHttpBinding>
    <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"
     useDefaultWebProxy="true">
     <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" />
     </security>
    </binding>
   </basicHttpBinding>
  </bindings>
  <client>
   <endpoint address="http://mySite/theService.asmx"
    binding="basicHttpBinding" bindingConfiguration="AirportInfoSoap"
    contract="AirportInfoService.AirportInfoSoap" name="AirportInfoSoap" />
  </client>
  <behaviors>
      <endpointBehaviors>
            <behavior name="SOAPBehavior">
                  <enableWebScript/>
            </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
            <behavior name="UIControlPopulationBehavior">
                  <serviceMetadata httpGetEnabled="true"/>
                  <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
      </serviceBehaviors>
  </behaviors>
  <services>
      <service behaviorConfiguration="UIControlPopulationBehavior" name="UIControlPopulation">
            <endpoint address="" binding="webHttpBinding" contract="IUIControlPopulation" behaviorConfiguration="SOAPBehavior"/>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
  </services>
</system.serviceModel>


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.
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 ?
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).
ASKER CERTIFIED SOLUTION
Avatar of Aaron Jabamani
Aaron Jabamani
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial