简体   繁体   中英

Use URL to call wcf service instead of ip or localhost

I hosted my WCF service on one static IP but when net disconnected then dynamic IP of system changes so my service stop working.

Now what I want to do is instead of using IP address or localhost I want to call service using URL.

This is my web.con file code for

<system.serviceModel>
<services>
    <service name="abc.bca" behaviorConfiguration="mexendpoint">
      <endpoint address="" binding="basicHttpBinding" contract="abc.Ibca">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost/bca.svc" />
        </baseAddresses>
      </host>
    </service>
</services>

And this is how I define an IP address for calling through mobile application suppose that below is my static IP.

117.87.21.12

So instead of call static IP can I redirect it to any URL like techit@.com

The issue is more related to Domain Name System. Generally, we could call the service with the computer name.

http://myserverhostname:xxx/service.svc

If we want to add the custom domain name, we should have an understanding on the DNS system,
https://en.wikipedia.org/wiki/Domain_Name_System
https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/plan/reviewing-dns-concepts
For example, we want to access the computer with a bespoke name, we should ensure it located in the right dns name since the Domain Name System is recursively analyzed. One more thing I want to share with you is the local “Hosts” file will be used preferentially when the domain name is resolved. Therefore, we could achieve it by add an entry to the file ( located in the System32/drivers/etc/hosts file). You could refer to the below link.
https://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/
Feel free to let me know if there is anything I can help with.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM