Consume web service from Class Library

12,424

Solution 1

Service Reference is for Windows Communication Foundation (WCF) services and WCF Data Services where as Web Reference is used when using 'legacy' or asmx web services.

So for 'asmx' you should use web reference and not service reference.

http://alexduggleby.com/2008/08/24/add-web-reference-instead-of-service-reference-in-visual-studio-2008/

Regarding the error:
WCF services expose Metadata that enables them to interact with different kinds of endpoints and data. .NET 2.0 asmx webservices only have one endpoint @SOAP. So 'asmx' web services does not expose any metadata due to which the error occurs.

Solution 2

no it doesnt need,you need to copy webservice configuration to app config of target executable files,because when you put the webservice in library when you calling it from library ,the webservice looks for config from .exe.config that not exist

you can set webservice url programmatically like what i did

  AC.CCRS.WebService.MyWebServices c = new AC.CCRS.WebService.MyWebServices ();
            c.Url =... "the webservice host url
Share:
12,424
iKode
Author by

iKode

Updated on June 12, 2022

Comments

  • iKode
    iKode almost 2 years

    I have successfully created an ASP.net website to make calls to a Soap Web service.

    Now I need to turn it into a Class Library that I can call via Com from Classic ASP.

    This post on Consume web service in asp.net app from a class library says that I need to add the web service as use "Add Service Reference" instead of "Add Web Reference" to add a reference to the Webservice.

    When I try to do that I get an error:

    Metadata contains a reference that cannot be resolved: 'http://theURL.com:8008/asmx/publicServiceAddress.asmx?wsdl'.
    There was an error downloading 'http://theURL.com:8008/asmx/publicServiceAddress.asmx?wsdl'.
    Unable to connect to the remote server A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 77.95.80.35:8008 Metadata contains a reference that cannot be resolved: 'http://theURL.com/asmx/publicServiceAddress.asmx'. Metadata contains a reference that cannot be resolved: 'http://theURL.com/asmx/publicServiceAddress.asmx'.
    If the service is defined in the current solution, try building the solution and adding the service reference again.

    ...but when I click on advanced and then add then "Add Web Reference" I can add it fine.

    Questions:

    1) Is it necessary to use "Add Service Reference" instead of "Add Web Reference"?
    2) Why, what's the difference?
    3) What are potential causes of this error, and how can I figure this out, for instance I don't know why it's going to port 8080 to look for the WSDL http://theURL.com:8008/asmx/reguspublic.asmx?wsdl when it should go to http://theURL.com/asmx/reguspublic.asmx?wsdl

  • iKode
    iKode almost 13 years
    How can I tell if the web service is a WCF service or a legacy service?
  • A G
    A G almost 13 years
    asmx |.net 2.0 or before = legacy, svc = wcf.