Consuming a web service in VS 2008 ASP.Net project

Discussion in 'ASP .Net' started by William LaMartin, Mar 24, 2009.

  1. In Visual Studio 2008, consuming a web service is a bit different from in VS
    2005 in an ASP.Net project.

    It goes something like this

    Dim ds As New Data.DataSet
    Dim url As New
    System.ServiceModel.EndpointAddress("http://www.MyService.asmx")
    Dim ws As New MyService.Service1SoapClient("Service1Soap")
    ws.Endpoint.Address = url

    ds = ws.GetData()

    where GetData is a method of the service that returns a dataset.

    My problem is that the application runs fine from within Visual Studio, but
    when I deploy it, I will receive the error message:

    "Could not find endpoint element with name 'Service1Soap' and contract
    'MyService.Service1Soap' in the ServiceModel client configuration section.
    This might be because no configuration file was found for your application,
    or because no endpoint element matching this name could be found in the
    client element. "

    unless I copy what is below from the web.config of the Visual Studio project
    and add it to the Web.config of the web site. I don't really like doing
    this, since I can foresee a problem if I add many applications to the site
    that use web services.

    Is there another way--like a configuration file that can go inside the
    application folder at the site?

    <system.serviceModel>
    <bindings>
    <basicHttpBinding>
    <binding name="Service1Soap" closeTimeout="00:01:00"
    openTimeout="00:01:00"
    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
    maxBufferSize="4000000" maxBufferPoolSize="524288"
    maxReceivedMessageSize="4000000"
    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://www.MyService.asmx"
    binding="basicHttpBinding" bindingConfiguration="Service1Soap"
    contract="MyService.Service1Soap" name="Service1Soap" />
    </client>
    </system.serviceModel>
     
    William LaMartin, Mar 24, 2009
    #1
    1. Advertising

  2. William LaMartin

    Mr. Arnold Guest

    "William LaMartin" <> wrote in message
    news:%...
    > In Visual Studio 2008, consuming a web service is a bit different from in
    > VS 2005 in an ASP.Net project.
    >
    > It goes something like this
    >
    > Dim ds As New Data.DataSet
    > Dim url As New
    > System.ServiceModel.EndpointAddress("http://www.MyService.asmx")
    > Dim ws As New MyService.Service1SoapClient("Service1Soap")
    > ws.Endpoint.Address = url
    >
    > ds = ws.GetData()
    >
    > where GetData is a method of the service that returns a dataset.
    >
    > My problem is that the application runs fine from within Visual Studio,
    > but when I deploy it, I will receive the error message:
    >
    > "Could not find endpoint element with name 'Service1Soap' and contract
    > 'MyService.Service1Soap' in the ServiceModel client configuration section.
    > This might be because no configuration file was found for your
    > application, or because no endpoint element matching this name could be
    > found in the client element. "
    >
    > unless I copy what is below from the web.config of the Visual Studio
    > project and add it to the Web.config of the web site. I don't really like
    > doing this, since I can foresee a problem if I add many applications to
    > the site that use web services.
    >
    > Is there another way--like a configuration file that can go inside the
    > application folder at the site?


    No, a Web application with a Web.config is the root configuration file, and
    it has to be in that config file and nowhere else, that I know about.

    If you're complaining about this, wait until you see what has to be in
    ASP.Net's Web.config and what must be in a WCF's Web service Web.config to
    consume a WCF Web service. :)
     
    Mr. Arnold, Mar 24, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ezhil
    Replies:
    1
    Views:
    645
    Bruce Barker
    Sep 19, 2005
  2. DNB
    Replies:
    1
    Views:
    264
  3. dgleeson422111

    Consuming local web service - ok, remote web service -problem?

    dgleeson422111, Jan 26, 2010, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    920
    dgleeson422111
    Jan 26, 2010
  4. Curt K
    Replies:
    3
    Views:
    475
    John Saunders [MVP]
    Jun 15, 2007
  5. DNB
    Replies:
    1
    Views:
    318
    John Saunders [MVP]
    Jan 20, 2008
Loading...

Share This Page