none
WCF Add Service Reference problem: No connection could be made because the target machine actively refused it RRS feed

  • Question

  • Hi,

    If I add a WCF Service Library to my solution I can add it to my test project with Service Reference. It automatically Discovers all urls and if I click on the expand (play) button it also shows the services. If I add to this service my own implementation within NopCommerce I do not get the service to render 'mex' endpoint.

    <%@ ServiceHost Language="C#" Debug="true" Service="Nop.Plugin.Misc.QEWebServices.ERPService" CodeBehind="ERP.svc.cs" %>

    My web.config and app.config look like this:

    <?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" /> <httpRuntime targetFramework="4.5"/> </system.web> <appSettings> <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> </appSettings> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior> <dataContractSerializer maxItemsInObjectGraph="2147483647" /> <!-- To avoid disclosing metadata information, set the values below to false before deployment --> <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true" /> </behavior> </serviceBehaviors> </behaviors> <bindings> <wsHttpBinding> <binding name="HttpsBigMessage" receiveTimeout="20:10:00" sendTimeout="20:10:00" maxReceivedMessageSize="2147483647"> <security mode="Transport"> <transport clientCredentialType="None" /> </security> </binding> </wsHttpBinding> <basicHttpBinding> <binding name="HttpBigMessage" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="65536"> <security mode="None" /> </binding> </basicHttpBinding> </bindings> <services> <service name="Nop.Plugin.Misc.QEWebServices.ERPService" > <host> <!--http://+:8731/Design_Time_Addresses--> <baseAddresses> <add baseAddress="http://localhost:8734/Design_Time_Addresses/Nop.Plugin.Misc.QEWebServices/Remote/ERP.svc/" /> </baseAddresses> </host> <endpoint address="" binding="basicHttpBinding" contract="Nop.Plugin.Misc.QEWebServices.IERPService"/> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> <protocolMapping> <add binding="basicHttpsBinding" scheme="https" /> </protocolMapping> <!--<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />--> </system.serviceModel> </configuration>

    I receive error:

    System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
       at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
       at System.Reflection.RuntimeModule.GetTypes()
       at System.Reflection.Assembly.GetTypes()
       at Microsoft.Tools.SvcHost.ServiceHostHelper.LoadServiceAssembly(String svcAssemblyPath)

    And in details of the WCF hosting window:

    There was an error downloading 'http://localhost:8734/Design_Time_Addresses/Nop.Plugin.Misc.QEWebServices/Remote/ERP.svc/mex/_vti_bin/ListData.svc/$metadata'.
    Unable to connect to the remote server
    No connection could be made because the target machine actively refused it 127.0.0.1:8734
    Metadata contains a reference that cannot be resolved: 'http://localhost:8734/Design_Time_Addresses/Nop.Plugin.Misc.QEWebServices/Remote/ERP.svc/mex'.
    There was no endpoint listening at http://localhost:8734/Design_Time_Addresses/Nop.Plugin.Misc.QEWebServices/Remote/ERP.svc/mex that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
    Unable to connect to the remote server
    No connection could be made because the target machine actively refused it 127.0.0.1:8734
    If the service is defined in the current solution, try building the solution and adding the service reference again.

    I have two warnings in my output box:

    1>\Workspaces\nopCommerce_3.20_Source\Plugins\Nop.Plugin.Misc.QEWebServices\App.config(37,16,-1,-1): warning : WCF configuration validation warning: The 'name' attribute is invalid - The value 'Nop.Plugin.Misc.QEWebServices.ERPService' is invalid according to its datatype 'serviceNameType'.
    1>\Workspaces\nopCommerce_3.20_Source\Plugins\Nop.Plugin.Misc.QEWebServices\App.config(44,57,-1,-1): warning : WCF configuration validation warning: The 'contract' attribute is invalid - The value 'Nop.Plugin.Misc.QEWebServices.IERPService' is invalid according to its datatype 'serviceContractType'.
    

    I do not like those warnings. Whatever I do...It drives me nuts...help appreciated.

    J.


    Friday, February 14, 2014 5:52 PM

Answers

  • Hi,

    First please try to check if the service is working in the brower.

    Then I saw that you were hosting the WCF Service Library in the IIS, so please try to check the following blog to check if you have done it well.

    #Hosting a WCF Service Library in IIS:
    http://continuouslyintegrating.blogspot.in/2008/10/hosting-wcf-service-library-in-iis.html .

    Also you have set the following for the basicHttpBinding:

     <basicHttpBinding>
            <binding name="HttpBigMessage" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="65536">
              <security mode="None" />
            </binding>
     </basicHttpBinding>

    But you did not apply the binding config to the endpoint, so please try to modify your endpoint as following:

    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="HttpBigMessage" 
              contract="Nop.Plugin.Misc.QEWebServices.IERPService"/>

    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, February 17, 2014 5:29 AM
    Moderator