0

I have a web application in Angular and i have also created the WCF service in this web application. When i run the web application the URL is localhost:53536/#/Page. Service address is localhost:53536/Service/Service/svc. I hosted the web application and both web app and WCF service is working fine. But i want to host web service on different port or on different address. How can i do this. Here is my web.config

<system.serviceModel>

    <behaviors>

      <serviceBehaviors>

        <behavior name="" >

          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
    <bindings>
      <wsDualHttpBinding>
        <binding name="MobileServiceBinding" closeTimeout="00:00:05" openTimeout="00:00:05">
          <readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
      </wsDualHttpBinding>
    </bindings>
    <services>
      <service name="Web.Mobile.MobileService" >
        <endpoint address="" binding="wsDualHttpBinding"  bindingConfiguration="MobileServiceBinding" contract="Web.Mobile.IMobileService" />
      </service>
    </services>
  </system.serviceModel>

How i can assign different address to WCF service?

Umer Waheed
  • 4,044
  • 7
  • 41
  • 62

1 Answers1

1

This sounds like the auto-assigned port from your project settings while the address of your endpoint configuration is empty.

Just modify address to your needs when deploying your web service

<services>
    <service name="Web.Mobile.MobileService" >
        <endpoint address="http://whatever.you.like:1337" binding="wsDualHttpBinding"  bindingConfiguration="MobileServiceBinding" contract="Web.Mobile.IMobileService" />
     </service>
</services>

or modify the project configuration for running / debugging your web service in Visual Studio.

Filburt
  • 17,626
  • 12
  • 64
  • 115
  • thank for reply. I have already did this. Like as you said i have set the address http://MobileService:1337. When i hit this url in browser this error comes 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. To fix this problem, specify a relative uri for endpoint 'http://mobileservice:1337/'. – Umer Waheed Jul 11 '18 at 06:42
  • As it seems answers on [WCF Error : Relative end point addresses ](https://stackoverflow.com/q/15681573/205233) suggest that leaving `address` blank is required for `multipleSiteBindingsEnabled` so you will have to abandon that or you'll have to stick with an endpoint address relative to your website, not being able to use a different port. Sorry that I missed out on the specific binding in your case. – Filburt Jul 11 '18 at 07:17
  • Ok. What if i set false to multipleSitebinded. It is still not working. – Umer Waheed Jul 11 '18 at 07:19
  • Did you also try setting the `baseaddress` as suggested in [this answer](https://stackoverflow.com/a/42423452/205233)? – Filburt Jul 12 '18 at 07:13
  • I guess your only chance is to move your WCF service to a dedicated project - I'm not familiar with the specific implications of `wsDualHttpBinding` for your project but to me it looks as the only way to achieve what you want. – Filburt Jul 12 '18 at 07:25