Use Https when calling API Management

I was trying to use the Azure API Management connector in a Logic App, but I continued to get a Http 404 Resource Not Found error. I could call the very same API Management service via Postman. I could also use a Http action to call the API Management service. Question: why can’t I call the service via the Azure API Management connector?

In the end it turned out everything was OK with the API Management Service and the backend service. The only thing you will have to do, is active option Https on the service.

[box type=”info”] Activate Https when you want to call a service via the Azure API Management connector in a logic app! If you call a http endpoint you will receive a Http 404 Resource Not Found error. [/box]

WCF Service with Http endpoint and Https endpoint

To have a WCF webservice with a http and a https endpoint.
– Install the service under the default website. Don’t install the webservice twice under both the DefaultWebSite and a SecureWebsite.
– Create a self-signed certificate.
– Edit bindings of the Default Website. Add binding for port 80 (http) and port 443 (https).
– Change web.config file in line with the example below:

<system.serviceModel>
<bindings>
<customBinding>
        <binding name=”RawReceive”>
          <webMessageEncoding webContentTypeMapperType=”Rfs.Integration.Common.REST.ContentTypeMapper.XmlContentTypeMapper, Rfs.Integration.Common.REST.ContentTypeMapper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e01eb028bb23e431″ />
          <httpTransport manualAddressing=”true” maxReceivedMessageSize=”524288000″ transferMode=”Streamed” />
        </binding>
        <binding name=”RawReceiveSecure”>
          <webMessageEncoding webContentTypeMapperType=”Rfs.Integration.Common.REST.ContentTypeMapper.XmlContentTypeMapper, Rfs.Integration.Common.REST.ContentTypeMapper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e01eb028bb23e431″ />
          <httpsTransport manualAddressing=”true” maxReceivedMessageSize=”524288000″ transferMode=”Streamed” />
        </binding>
</customBinding>
</bindings>
<services>
<service behaviorConfiguration=”RESTServiceBehavior” name=”Rfs.Integration.Common.REST.MessageService.MessageService”>
        <endpoint address=”” behaviorConfiguration=”RESTEndpointBehavior”
          binding=”customBinding” bindingConfiguration=”RawReceive” contract=”Rfs.Integration.Common.REST.MessageService.IMessageService” />
        <endpoint address=”” behaviorConfiguration=”RESTEndpointBehavior”
          binding=”customBinding” bindingConfiguration=”RawReceiveSecure” contract=”Rfs.Integration.Common.REST.MessageService.IMessageService” />
      </service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name=”RESTServiceBehavior” >
<serviceMetadata httpGetEnabled=”true” httpsGetEnabled=”true”/>
<serviceDebug includeExceptionDetailInFaults=”false”/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name=”RESTEndpointBehavior”>
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled=”true” multipleSiteBindingsEnabled=”true” />
</system.serviceModel>

Creating a https webservice

Om een http webservice te creeëren, heb je eerst een self signed certificate nodig. Run Visual Studio Command Prompt as an administrator en voer de volgende commando’s uit:

//Create self-signed certificate for the root authority
makecert -n “CN=Erpobizzw004CA” -r -sv Erpobizzw004CA.pvk Erpobizzw004CA.cer -sky exchange
//Als er gevraagd wordt om een password, typ dan bijvoorbeeld password: biztalk

//Add certicate to Trusted Root Certifcate Authority store
certmgr -add Erpobizzw004CA.cer -s -r localmachine root
//This tool also opens the mmc, but you also perform the steps manually:

// Start/Run mmc
// Add snap-in Certificates, choose Computer Account
//Expand node Trusted Root Certifcate Authority store in the MMC
//Right-click Certificates
//Import, select Erpobizzw004CA.cer

//Install in personal store
makecert -sky exchange -sk localhost -iv Erpobizzw004CA.pvk -n “CN=localhost” -ic Erpobizzw004CA.cer localhost.cer -sr localmachine -ss My
//enter password: biztalk

Nadat je het self-signed certificate hebt, kun je in IIS een nieuwe website creeëren naast de default website. Noem de website bijvoorbeeld SecureWebSite en gebruik als filepad C:\inetpub\wwwrootsecure. Vervolgens kun je aan de nieuwe
Voor een toelichting, zie de volgende link: http://www.iis.net/learn/manage/configuring-security/how-to-set-up-ssl-on-iis

  • Right-click de website en kies Edit Bindings. Voeg een binding toe voor https, port 443 en selecteer het aangemaakte self-signed certificate.
  • De tweede stap. Configure SSL settings is niet nodig. Volgens mij gebruik je deze stap alleen als je een certificate wilt gebruiken als client credential.

Let op. Als je nu je applicatie installeert onder de nieuwe website, dan moet je een service behavior httpsGetEnabled toevoegen i.p.v. httpGetEnabled.

<serviceBehaviors>
<behavior name =”RESTServiceBehavior”>
<serviceMetadata httpsGetEnabled=”true”/>
<serviceDebug includeExceptionDetailInFaults=”true”/>
</behavior>
</serviceBehaviors>

Zorg ook dat de website gestart is. Noot: Niet alleen de webserver moet gestart zijn, maar ook de websites. Voor een check. Right-click de website en kies voor Manage Website. Je kunt nu de website starten of stoppen.

Voor de test, kun je nu in Content view de svc file selecteren en kiezen voor browse. Vervolgens wordt de service file geopend via https en zie je een wsdl pagina.