locked
WCF Deployment issues RRS feed

  • Question

  • User1063851105 posted

    Hi, I have a web service that I've written in VS2012.

    All seems fine when i click the Run button and its hosts locally in the WCF test client.
    I can reference it from another application and it all behaves as I intended.

    The problem comes when I try to move the service to the remote server where it will live.
    I click the Publish button and it will upload the files to where i need them, but i cant reference it from another application.

    When i look into this further, the file structures created seem to differ between the local and published versions.

    My config file is shown below....

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    
    <system.web>
    <compilation debug="true" />
    </system.web>
    <system.serviceModel>
    <bindings>
    <basicHttpBinding>
    <binding name="HttpBinding"
    hostNameComparisonMode="StrongWildcard"
    maxBufferPoolSize="2147483647"
    maxBufferSize="2147483647"
    maxReceivedMessageSize="2147483647"
    receiveTimeout="00:10:00">
    <security mode="Transport"/>
    </binding>
    </basicHttpBinding>
    </bindings>
    <services>
    <service name="MyServiceLibrary.MyService">
    <host>
    <baseAddresses>
    <add baseAddress="http://mywebaddress.com/" />
    </baseAddresses>
    </host>
    
    <endpoint address="" binding="basicHttpBinding" contract="AgriServiceLibrary.IAgriService" bindingName="HttpBinding"/>
    
    <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange"/>
    </service>
    </services>
    <behaviors>
    <serviceBehaviors>
    <behavior>
    <serviceMetadata /> 
    <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
    </serviceBehaviors>
    </behaviors>
    </system.serviceModel>
    
    </configuration>
    

    Can someone please point me in the right direction?
    I'm either missing something or I'm being an idiot.
    Thanks

    Monday, March 10, 2014 11:36 AM

Answers

  • User-417640953 posted

    This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection. 

    Hi Gimbal5401,

    Thanks for your response.

    This error usually caused by multiple http bindings defined at web site. As said "IIS has web sites, which are containers for virtual applications which contain virtual directories.

    The application in a site can be accessed through one or more IIS binding. binding protocol and binding information.

    Binding protocol defines the scheme over which communication occurs, and binding information is the information used to access the site."

    # If it is the asp.net 4.0, you can set the web.config like below.

    <system.serviceModel> 
         <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 

    # If ASP.NET 2.0/3.0/3.5, you can add the following lines to your web.config.

    <system.serviceModel> 
         <serviceHostingEnvironment> 
              <baseAddressPrefixFilters> 
                   <add prefix="http://www.YourHostedDomainName.com"/> 
              </baseAddressPrefixFilters> 
         </serviceHostingEnvironment> 
    </system.serviceModel> 

    There is a similar issue, please refer to the solutions below.

    http://bartwullems.blogspot.com/2012/04/wcf-service-error-this-collection.html

    http://stackoverflow.com/questions/561823/wcf-error-this-collection-already-contains-an-address-with-scheme-http

    Thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 12, 2014 9:54 PM

All replies

  • User-417640953 posted

    Hi Gimbal5401,

    Thank you post the issue to asp.net forum.

    Based on your description, I understand you want to call the web service deployed on remote server in local application.

    Please right click the application in visual studio 2012, then choose "add service reference".

    Input the service matedata address to the Address textbox. Click "Go" button, then click "OK".

    That will generate a service proxy class in your application. So you can call the service by proxy.

    Chapter 14: Internet - Web to Remote WCF Using Transport Security (Trusted Subsystem, TCP), please refer to below.

    http://msdn.microsoft.com/en-us/library/ff650091.aspx

    Hope that helps, thanks.

    Best Regards!

    Wednesday, March 12, 2014 5:36 AM
  • User1063851105 posted

    Hi,

    thanks for the reply.

    Unfortunately, I cant get this to work.
    I've been trying this and have managed to get to the point where i have managed to get the Add Reference to see the service but get the following message:

    This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection. 

    I'm looking into this at the moment and have come across several solutions, none of which seem to work.

    my config now looks like.....

    <?xml version="1.0"?>
    <configuration>
    
      <system.web>
        <compilation debug="true"/>
        <customErrors mode="Off"/>
      </system.web>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="HttpBinding" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" receiveTimeout="00:10:00">
              <security mode="Transport"/>
            </binding>
          </basicHttpBinding>
        </bindings>
        <services>
          <service name="MyServiceLibrary.MyService" behaviorConfiguration="MyServiceLibrary.MyService">
            <host>
              <baseAddresses>
                <add baseAddress="http://myserveraddress.com/" />
              </baseAddresses>
            </host>
            <endpoint address="" binding="basicHttpBinding" contract="MyServiceLibrary.IMyService" bindingName="HttpBinding" behaviorConfiguration="" >
    
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" behaviorConfiguration=""></endpoint>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
              <behavior name="MyServiceLibrary.MyService">
                 <serviceMetadata />
              </behavior>
    
        
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    
    </configuration>
    

    Like I said above, I think I'm missing something obvious. I just cant see it.

    Really appreciate the help.

    Wednesday, March 12, 2014 6:27 AM
  • User-417640953 posted

    This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection. 

    Hi Gimbal5401,

    Thanks for your response.

    This error usually caused by multiple http bindings defined at web site. As said "IIS has web sites, which are containers for virtual applications which contain virtual directories.

    The application in a site can be accessed through one or more IIS binding. binding protocol and binding information.

    Binding protocol defines the scheme over which communication occurs, and binding information is the information used to access the site."

    # If it is the asp.net 4.0, you can set the web.config like below.

    <system.serviceModel> 
         <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 

    # If ASP.NET 2.0/3.0/3.5, you can add the following lines to your web.config.

    <system.serviceModel> 
         <serviceHostingEnvironment> 
              <baseAddressPrefixFilters> 
                   <add prefix="http://www.YourHostedDomainName.com"/> 
              </baseAddressPrefixFilters> 
         </serviceHostingEnvironment> 
    </system.serviceModel> 

    There is a similar issue, please refer to the solutions below.

    http://bartwullems.blogspot.com/2012/04/wcf-service-error-this-collection.html

    http://stackoverflow.com/questions/561823/wcf-error-this-collection-already-contains-an-address-with-scheme-http

    Thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 12, 2014 9:54 PM
  • User1063851105 posted

    Thats fixed it.

    Thank you. :)

    Thursday, March 13, 2014 5:55 AM