Trying to deploy a super barebones WCF Web Service and test it locally. I'm getting an error:
Could not find a base address that matches scheme https for the endpoint
with binding BasicHttpBinding. Registered base address schemes are [http].
I'll include my endpoint tags from the web.config file here:
<services>
<service name="Company.PrototypeWebService.PrototypeWebService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="secureHTTPBinding" contract="Company.PrototypeWebService.ServiceContracts.IPrototypeWebService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
Is there something I'm missing here? I'm new to web service development.
This is because your base address is Http, but I see that your metadata endpoint uses https, which is the cause of the error,modify your Service:
<services>
<service name="Company.PrototypeWebService.PrototypeWebService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="secureHTTPBinding" contract="Company.PrototypeWebService.ServiceContracts.IPrototypeWebService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
Modify mexHttpsBinding to mexHttpBinding.
If you want to use https binding, you need to configure the SSL certificate on the server. Normally, it is more convenient to use https in IIS.
UPDATE
If hosted in IIS, we need to create the following WCF project:
The directory of this project looks like this:
We can deploy the project directly to IIS, set the base address when deploying in IIS, we do not need to configure the base address in the configuration file. This is the base address of the service:
After the deployment is successful, we click on the .svc file to view the service:
Related
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://learn.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.
I am just starting to learn WCF. I have successfully set up a WCF service with host console app. The service maps to SQL Server with Entity Framework. I then have a WPF client app which consumes the service. This all works fine in Dev, both the service and client app running from my machine:
<endpoint address="http://localhost:8081/" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IRegimesService" contract="RegimesService.IRegimesService"
name="BasicHttpBinding_IRegimesService" />
I have now transferred the service and host onto my new VM. The service host runs fine. I am now trying to configure the client app endpoint to connect to the service. I think the HTTP address is incorrect:
Service app.config:
<services>
<service name="diiRegimesService.RegimesService">
<endpoint address="" binding="basicHttpBinding" contract="diiRegimesService.IRegimesService"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8082" />
</baseAddresses>
</host>
</service>
</services>
Client app.config:
<client>
<endpoint address="http://emea-myserver01.emea.basketballinfo.com/localhost:8082/" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IRegimesService" contract="RegimesService.IRegimesService"
name="BasicHttpBinding_IRegimesService" />
</client>
The server credentials for remote desktop are: emea-myserver01.emea.basketballinfo.com
I currently don't specify a username & password in my client app.config.
The service is running on the server. I'm getting an exception trying to add the service reference in the client app.
Add Service Reference- Adress: http://EMEA-myserver01.emea.basketballinfo.com
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://emea-myserver01.emea.basketballinfo.com/'.
You need to make sure the server is able to resolve the full domain name.
Also, the address url provided in the client configuration snippet <endpoint address="http://emea-myserver01.emea.basketballinfo.com/localhost:8082/ does not seem valid. Perhaps you want to use <endpoint address="http://emea-myserver01.emea.basketballinfo.com:8082/
After implemeting a WCF service, hosting it on the IIS Server, it returned with the below error.
EndpointNotFoundException was unhandled by user code There was no
endpoint listening at XXXXX that could accept the message. This is
often caused by an incorrect address or SOAP action. See
InnerException, if present, for more details.
That service is identically has the same implementation and configuration of 5 running services with no errors.
when I tried to figure out what is going on the IIS server, the below screenshot.
So it seems that this specific service has no detected Contract. although I'm using the same configuration as below.
<service name="XX.XX.Provisioning.EldaftarManagementService">
<endpoint address="" binding="customBinding" bindingConfiguration="ProvisioningServiceBinding" bindingNamespace="http://XX.XX.com/XX/" contract="XX.XX.Provisioning.Eldaftar.IEldaftarManagementService" />
<endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="ProvisioningBasicBinding" bindingNamespace="http://XX.XX.com/provisioning/" contract="XX.XX.Provisioning.Eldaftar.IEldaftarManagementService" />
</service>
<service name="XX.XX.Provisioning.Common.UserManagement.UserManagementService">
<endpoint address="" binding="customBinding" bindingConfiguration="ProvisioningServiceBinding" bindingNamespace="http://XX.XX.com/XX/" contract="XX.XX.Provisioning.Common.UserManagement.IUserManagementService" />
<endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="ProvisioningBasicBinding" bindingNamespace="http://XX.XX.com/provisioning/" contract="XX.XX.Provisioning.Common.UserManagement.IUserManagementService" />
</service>
Kindly noted that when accessing the service.svc url it replies normally and the wsdl is shown. So that means it's hosted fine on the IIS.
Do I miss something?
Update:
Client config.
<endpoint address="https://XXX/EldaftarManagementService.svc" behaviorConfiguration="ProvisioningClientBehaviour" binding="customBinding" bindingConfiguration="ProvisioningServiceBinding" contract="EldaftarManagementService.IEldaftarManagementService" />
<endpoint address="https://XXX/UserManagement.svc" behaviorConfiguration="ProvisioningClientBehaviour" binding="customBinding" bindingConfiguration="ProvisioningServiceBinding" contract="UserManagementService.IUserManagementService" />
i notice sometime after reconfigure my service reference, the client config getting wsdl with server name. then i get EndpointNotFoundException exception.
example :
service reference is : http://192.168.61.2:1111/Service1.svc
but in the config endpoint address it show : http://serverName:1111/Service1.svc
After i change the config endpoint address with the service reference address , then it resolved. Not sure why but now every time when i reconfigure the endpoint address, i will manually change the config endpoint address to make sure it get the same address.
How do I get all the wcf 4.0 service addresses from each project in the Visual Studio solution when the services section endpoints in the web configs don’t specify an address or baseaddress? I intend to write the list of service addresses out to an aspx page. Any help would be appreciated.
Here's an example of one of the service sections in the web config.
<services>
<service name="ABC.Enterprise.Flight.FlightService">
<endpoint address="" binding="basicHttpBinding" name="ICRMManagement" contract="ABC.Enterprise.Flight.IFlightService"/>
<endpoint address="MexBasic" binding="mexHttpBinding" name="MexBasic" contract="IMetadataExchange" />
</service>
You could use WCF Discovery to find endpoints at runtime...
http://msdn.microsoft.com/en-us/library/dd456791.aspx
i have a few questions about the below config file:
<system.serviceModel>
<bindings />
<services>
<service behaviorConfiguration="WcfReporting.Service1Behavior"
name="WcfReporting.Service1">
<endpoint address=""
binding="basicHttpBinding" bindingConfiguration=""
contract="WcfReporting.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:5050/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfReporting.Service1Behavior" >
<!-- To avoid disclosing metadata information, set the value below to false
and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment to
avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Why when I hit F5 to restart the service, the service starts with this URL http://localhost:2752/ ... why not 5050 as I specified in baseAddresses.
How how can I add another endpoint. I tried with endpoint address="/Address2" binding="basicHttpBinding" contract="WcfReporting.IService1" />
should I how be able to access the service, not only with http://localhost/VirtualDir/ but also with http://localhost/VirtualDir/address2 or how does it work?
If you're hosting in Cassini from within Visual Studio 2005 or later, you can specify the port using Project/Properties/Web/Use Visual Studio Development Server/Specific Port.
By default the port will be auto-assigned - which isn't very helpful for Web Services as your clients will probably want to be using a fixed URL.
You don't need to specify <baseAddresses> in the config file when hosting in IIS or Cassini - the base URL is provided by the web server. The <baseAddresses> element is used when self-hosting.
How how can I add another endpoint. I
tried with endpoint
address="/Address2"
binding="basicHttpBinding"
contract="WcfReporting.IService1" />
The addresses you specify in this endpoint need to be local and relative - e.g. just specify
<endpoint address="Address2"
binding="basicHttpBinding"
contract="WcfReporting.IService1" />
and this will create an endpoint at the complete address of
net.tcp://localhost:5050/Address2
But as Darin has already pointed out - if you use IIS / WAS to host your service, the virtual directory where your *.svc file resides will take precedence and the base addresses specified will be ignored. In order to really use the base addresses, you'll need to self-host the service in a console app or Windows service.
Marc
If you use a web server (such as Cassini or IIS) to host your WCF service the base address will be provided from this server. Also note that you cannot use TCP bindings over HTTP. If you want to be able to set the base address property you need to host the service yourself (for example in NT service, console or windows application).