Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding WCF Service Reference with https endpoint

My WCF service application works over http and https, however, when I add a service reference (with the https url) to it in my client, Visual Studio 2010 sets the endpoint in the config file to http. It doesn't appear to be as simple as changing that config endpoint to https since there are multiple files behind the scenes doing things with the xsd's and reference the http endpoint. How can I setup my service / client to force https so that it correctly sets the endpoint?

When I try to manually change the endpoint in the config file and set security mode to "Transport" I get this error:

Exception Message: There was no endpoint listening at https://myservice/AvailabilityService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

I can, however, see that endpoint in IE, and am debugging locally. After I add my service reference with https and search the solution for its http equivolent, it finds a wsdl file referencing http, a configuration.svcinfo, and a configuration91.svcinfo that utilizes the http url instead of https

Here's my server side config:

<?xml version="1.0"?> <configuration>   <system.web>     <compilation debug="true" targetFramework="4.0" />   </system.web>   <system.serviceModel>     <behaviors>       <serviceBehaviors>         <behavior>           <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />           <serviceDebug includeExceptionDetailInFaults="true"/>         </behavior>       </serviceBehaviors>     </behaviors>     <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />   </system.serviceModel>  <system.webServer>     <modules runAllManagedModulesForAllRequests="true"/>   </system.webServer> </configuration> 

.. And the client side config:

<system.serviceModel>     <bindings>       <basicHttpBinding>         <binding name="BasicHttpBinding_IAvailabilityService" closeTimeout="00:01:00"             openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"             allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"             maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"             messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"             useDefaultWebProxy="true">           <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"               maxBytesPerRead="4096" maxNameTableCharCount="16384" />           <security mode="Transport">             <transport clientCredentialType="None" proxyCredentialType="None"                 realm="" />             <message clientCredentialType="UserName" algorithmSuite="Default" />           </security>         </binding>       </basicHttpBinding>     </bindings>     <client>       <endpoint address="https://myservice/AvailabilityService.svc"           binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAvailabilityService"           contract="PaymentAvailabilityService.IAvailabilityService"           name="BasicHttpBinding_IAvailabilityService" />     </client>   </system.serviceModel> 

Perhaps I'm better off manually consuming the services in code?

like image 255
Chris Klepeis Avatar asked Nov 07 '11 15:11

Chris Klepeis


People also ask

How can I combine the WCF services config for both http and https in one web config?

In IIS 7.5, go to your site and click on Bindings under Edit Site Action. Ensure that both http & https have been added. Then you need to create a binding for HTTP under <basicHttpBinding> , with security mode set to none. Add the newly created binding configuration to http endpoint.

How do I add a WCF service reference in a net core 3.1 application?

NET Standard project, this option is available when you right-click on the Dependencies node of the project in Solution Explorer and choose Manage Connected Services.) On the Connected Services page, select Add Service Reference. The Add service reference page opens. Select WCF Web Service, and then choose Next.


1 Answers

You need to change your binding to use transport security to use HTTPS

Transport Security

Your server side binding should be configured for https as well as client:

<bindings>   <basicHttpBinding>     <binding name="httpsBinding" allowCookies="true" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">       <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />       <security mode="Transport">         <transport clientCredentialType="None" />       </security>     </binding>   </basicHttpBinding> </bindings> <services>   <service name="yourNamespace.YourService" behaviorConfiguration="yourBehaviors">     <endpoint contract="yourNamespace.YourService" binding="basicHttpBinding" bindingConfiguration="httpsBinding" />   </service> </services> 
like image 77
Nick Nieslanik Avatar answered Sep 28 '22 19:09

Nick Nieslanik