Solved

WCF Config in Asp.net web site

Posted on 2010-11-17
13
2,574 Views
Last Modified: 2012-05-10
Hi

I am trying to get a WCF service running in an ASP.Net project (will run in IIS 7 but I can't get it work in visual studio for the moment). The reason why I need WCF is because I want to use MTOM encoding which is not available in a classic asp.net webservice. For the same reason I want to configure it so that I can upload large binary messages.

That means that I do need to specify the configuration of the service in web.config.

the service is located in a file called "albumservice.svc" in the root of the website, and the corresponding interface (Ialbumservice) is correctly implemented (albumservice class).

You can find below the web.config file I currently have. With this I am getting the following error when trying to view the service in a browser (the rest of the site works corretly):

Could not find a base address that matches scheme https for the endpoint with binding albumWSbinding. Registered base address schemes are [http].
[InvalidOperationException: Could not find a base address that matches scheme https for the endpoint with binding albumWSbinding. Registered base address schemes are [http].]
   System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses) +12230836
   System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress) +12228189
   System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection) +67

I keep looking around but it doesn't look like I am doing anything wrong. Removing the address tag of the endpoint doesn't help. If anyone has any suggestions, they are more than welcome!

thanks
Charles




<system.serviceModel>

    <services>

      <service name="albumservice" behaviorConfiguration="albumbehavior">

        <endpoint address="albumservice.svc"

                  binding="wsHttpBinding"

                  bindingConfiguration="albumWSbinding"

                  bindingName="albumWSbinding"

                  contract="Ialbumservice"

                  name="albumWSpoint"></endpoint>

        <endpoint binding="mexHttpBinding"

                  address="mex"

                  contract="IMetadataExchange"

                  name="albumMEXpoint"></endpoint>

      </service>

    </services>

    <bindings>

      <wsHttpBinding>

        <binding name="albumWSbinding" maxBufferPoolSize="5000000"

                 maxReceivedMessageSize="5000000"

                 messageEncoding="Mtom"

                 receiveTimeout="00:10:00">

          <security mode="Transport">

            <transport clientCredentialType="None"/>

          </security>

        </binding>

      </wsHttpBinding>

      <mexHttpBinding>

        <binding name="albumMEXbinding" >

        </binding>

      </mexHttpBinding>

    </bindings>

    <behaviors>

      <serviceBehaviors>

        <behavior name="albumbehavior">

          <serviceMetadata httpGetEnabled="true" />

          <serviceDebug includeExceptionDetailInFaults="true" />

        </behavior>

        <behavior name="">

          <serviceMetadata httpGetEnabled="true" />

          <serviceDebug includeExceptionDetailInFaults="false" />

        </behavior>

      </serviceBehaviors>

    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

  </system.serviceModel>

Open in new window

0
Comment
Question by:cm2187
  • 8
  • 5
13 Comments
 
LVL 21

Expert Comment

by:Alfred1
Comment Utility
Check this out.  This might help:

http://www.codewrecks.com/blog/index.php/2009/11/25/wcf-over-secure-transport/

http://www.codeproject.com/KB/WCF/WCF.aspx

You might need to use mexHttpsBinding rather than mexHttpBinding

and you might need to do this <serviceMetadata httpsGetEnabled="true"/> rather than <serviceMetadata httpGetEnabled="true"/>

0
 

Author Comment

by:cm2187
Comment Utility
But that's what I don't understand. I am not using https. I am trying to consume this service over regular http.
0
 
LVL 21

Expert Comment

by:Alfred1
Comment Utility
What is your base address anyway?  Did you set this up programmatically or within config?  Your base Address might be based on https.

something like this under services --> service tag.

   <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8081/test/" />
          </baseAddresses>
        </host>
0
 

Author Comment

by:cm2187
Comment Utility
my understanding was that if the service is hosted in IIS I should not need to specify the base address. Which would force me to hardcode in config some development specific variable.
0
 

Author Comment

by:cm2187
Comment Utility
actually asp won't even let me do it:

Error message
When 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' is set to true in configuration, the endpoints are required to specify a relative address. If you are specifying a relative listen URI on the endpoint, then the address can be absolute.
0
 
LVL 21

Expert Comment

by:Alfred1
Comment Utility
Oh yeah.  You generated a web site project (IIS Hosting) for the WCF service library.  Sorry, I was thinking of something else.

OK.  Your IIS website is based on http, right?  What is the address?  Is it something like "http://localhost/sample/albumservice.svc"?
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:cm2187
Comment Utility
And changing mexHttpBinding to mexHttpsBinding doesn't affect the error
0
 

Author Comment

by:cm2187
Comment Utility
Absolutely (while in development)
0
 

Author Comment

by:cm2187
Comment Utility
and what is weird is that I I add a new WCF service to the project (but don't alter anything to the web.config) this new service works. Obviously this is not good enough for me as I need that service to use a different encoding and max request size than the values by default. But it doesn't seem to be anything else than something wrong in my web.config
0
 
LVL 21

Expert Comment

by:Alfred1
Comment Utility
Just checking.  In my case, it is always http.  It should be http in development anyway.  :-)

That is just weird.  Anyway, I'll come back to this later.  I'm going to a meeting now. :-)
0
 

Author Comment

by:cm2187
Comment Utility
thanks!
0
 
LVL 21

Accepted Solution

by:
Alfred1 earned 500 total points
Comment Utility
OK.  This might be an IIS configuration issue.  Check the link below:

http://weblogs.asp.net/andrewrea/archive/2010/08/10/wcf-could-not-find-a-base-address-that-matches-scheme-https.aspx

I hope this helps.
0
 

Author Closing Comment

by:cm2187
Comment Utility
You did it!
removing the security part from the binding solved the problem! Would have never found that myself!

Thanks for your help!
Charles
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now