I have built an http based web service application with WCF and everything works. Now I try to convert it to run over https instead, but I can’t get it to work properly. I only receive "Bad Request". Currently this web service is running on IIS 7.5 and .NET 4.5. Anyone knows what i shall do to convert it from http to https and what I shall change on client side to be able to request an https web service instead of http.
Thx in advanced!
For Services Configuration use this
<services>
<service behaviorConfiguration="webServiceClientBehavior" name="My.Service.ServiceName">
<endpoint address="http://localhost/WCFClient" binding="basicHttpBinding" bindingConfiguration="secureBinding" contract="My.Service.IServiceName"/>
</service>
For Binding Configuration use below
<bindings>
<basicHttpBinding>
<binding name="secureBinding">
<security mode="Transport" />
</binding>
</basicHttpBinding>
For behavior configuration use below
<serviceBehaviors>
<behavior name="webServiceClientBehavior">
<!--For MetaData-->
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost/WCFClientMD"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
Related
Our client is getting below error when they try to call the web service via HTTPS request.
'There was no endpoint listening at https://XXXXXX/XXXX.svc - The remote server returned an error: (403) Forbidden.'
But the interesting part is, client successfully connects using the port which was used by the previous version. But new ports are not working. which means still client can call the new service using the old port. But once we change the bindings to the new https port, client is getting above error.
Below checks have been completed already.
1) Client can successfully access the URL from their server.
2) No firewall rules placed for the newly created port.
2) SSL root certificates are placed in the Trusted Root Certification folder.
Please let me know if you have any idea regarding this issue?
Thank you
According to your description, it seems that you may missed the https setting in the wcf application web.config file.
The following is a complete example of a web.config file for a WCF service using HTTPs.
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="MySecureWCFService.Service1">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="secureHttpBinding"
contract="MySecureWCFService.IService1"/>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="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>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
More details, you could refer to this article.
Thank you for your time all.
Proxy Server was blocking the requests come through the specific ports. Issue has been resolved after adding the ports into the proxy server.
I am trying to access a method within my wcf service through a url. I have followed many guides on how to hook up REST with wcf and access a method through a get. I get the following error
Content Type application/soap+xml; charset=utf-8 was not supported by service.
I know this has to do with my web.config being incorrect however, I have matched my service behavior configuration correctly. What am I missing here? Any help would be much appreciated.
<system.serviceModel>
<services>
<service name="Developer1.Core.Service.Developer1Service"
behaviorConfiguration="MyServiceBehavior" >
<endpoint
address="ws"
binding="wsHttpBinding"
contract="Developer1.Core.ServiceContracts.IDeveloper1Service" />
<endpoint
address="" behaviorConfiguration="webBehavior"
binding="webHttpBinding"
contract="Developer1.Core.ServiceContracts.IDeveloper1Service" />
<endpoint
address="mex" binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Seems the error occurs after I have added behavior name="MyServiceBehavior".
This is what I am trying to accomplish Making a WCF Web Service work with GET requests
SOLVED!!!
I solved the issue seems I had to do what i was doing within a service library instead of an application. So now I am handling REST with my wcf Library and the other methods are handled within my WCF Application. Seems app config and web config differ in a way. Then I went to solution properties and selected to start multiple projects at once. Now i can hit methods with get requests within the library and the application runs all the other methods that arent dealing with HTTP protocal. My solution has a WCF Library and WCF Application within it. The Application uses web.config and the library uses app.config. following this article http://weblogs.asp.net/kiyoshi/wcf-using-webhttpbinding-for-rest-services works with the App config. My WCF application then inherits from my service file within my Library and does not contain any extra service methods, it just runs the methods within my WCF Library. But the Library is set up to handle HTTP requests. Probably not the correct solution but it works for me.
I am trying to hook up one of my methods to be called after a get request is sent to the appropriate endpoint. When tampering with my web.config, I assigned a name to my behavior and i get the following error.
'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
Not sure why just assigning an attribute to my behavior throws this error.
<system.serviceModel>
<services>
<service name="Developer1.Core.Service.Developer1Service"
bindingConfiguration="myConfiguration" >
<endpoint
address="" behaviorConfiguration="webBehavior"
binding="webHttpBinding"
contract="Developer1.Core.ServiceContracts.IDeveloper1Service" />
<endpoint
address="mex" binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="myConfiguration">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Seems when i take away and don't have the name attribute, the error goes away. Any thoughts?
SOLVED!!!
I solved the issue seems I had to do what i was doing within a service library instead of an application. So now I am handling REST with my wcf Library and the other methods are handled within my WCF Application. Seems app config and web config differ in a way. Then I went to solution properties and selected to start multiple projects at once. Now i can hit methods with get requests within the library and the application runs all the other methods that arent dealing with HTTP protocal. My solution has a WCF Library and WCF Application within it. The Application uses web.config and the library uses app.config. following this article http://weblogs.asp.net/kiyoshi/wcf-using-webhttpbinding-for-rest-services works with the App config. My WCF application then inherits from my service file within my Library and does not contain any extra service methods, it just runs the methods within my WCF Library. But the Library is set up to handle HTTP requests. Probably not the correct solution but it works for me.
You defined myConfiguration as bindingConfiguration for the service. But you do not have binding configurations at all. You defined service behavior with this name. It has nothing to do with binding.
I am running an asp.net application within an IIS8 HTTPS web site.
The application is trying to access a HTTP web service but receives
this error on calling.
Error: The HTTP request was forbidden with client authentication scheme 'Anonymous'.
The call to the web service works from my development pc as it's running
locally as http.
I'm wondering if this is an IIS setting change or a web.config change or if HTTP
requests are allowed at all within a HTTPS site?
The web service being called is setup in the web.config as:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="APPO_LookupSoap">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://netdocs.xxxxxxxx.co.uk/TroposNetDocsIntegration/APPO_Lookup.asmx"
binding="basicHttpBinding" bindingConfiguration="APPO_LookupSoap"
contract="RM_WebService.APPO_LookupSoap" name="APPO_LookupSoap" />
</client>
</system.serviceModel>
Error Message:
[EndpointNotFoundException: There was no endpoint listening at "Link/MobileMotivation.asmx" that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.]
This is a MVC4 applcation, it works fine on the local machine. However when I implement it to the server which is the same server as the web service, it shows the error message.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MobileMotivationSoap" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://stuiis.cms.gre.ac.uk/bb116/FinalYear2/FinalYear2/MobileMotivation.asmx"
binding="basicHttpBinding" bindingConfiguration="MobileMotivationSoap"
contract="MobileMotivationService.MobileMotivationSoap" name="MobileMotivationSoap" />
</client>
You might need to edit the anonymous authentication settings.
Go to:
Server Manager
IIS
Connections > Sites > YourSite
Click Authentication > Enable
At this point you can select application pool identity.
More details here: A web site code can't connect to a soap service on the same server