Convert svc URL to REST API URL

When we publish BizTalk as REST Service, then it’s generate as below by default.

http://localhost/<ApplicationName>/Service1.svc

when we apply REST verb with this URL, then it’s become as below for Business User.

For GET Method:

http://localhost/<ApplicationName>/Service1.svc/Request?Data1={data}&Data2={data}

For POST Method:

http://localhost/<ApplicationName>/Service1.svc/Request

We can change the Service1 name with some other name but can’t change the .svc.

So, for outer world (Consumer), it’s look like they are consuming the WCF Service instead of REST Service.

So, making feel like as REST Service we need to do some small thing as below:

  • Install Microsoft Rewrite URL module 2.0 (it’s freeware) for IIS to accept the rewrite tags in service configuration files.

https://www.microsoft.com/en-in/download/details.aspx?id=7435

  • Add below rewrite module entries in service web.config file to enable us to use api name in service URL.

<system.webServer>

<rewrite>

<rules>

<rule name=”TestService1”>

<match url=”/Service1(.*)” />

<action type=”Rewrite” url=”Service1.svc/{R:0}” />

<conditions>

<add input=”{REQUEST_METHOD}” pattern=”GET” />

</conditions>

                     </rule>

                     <rule name=”TestService2”>

<match url=”/Service2(.*)” />

<action type=”Rewrite” url=”Service2.svc/{R:0}” />

<conditions>

<add input=”{REQUEST_METHOD}” pattern=”POST” />

</conditions>

</rule>

</rules>

</rewrite></system.webServer>

  • URL will refer as below instead of Service1.svc at postfix.

GET Method:

http://localhost/<ApplicationName>/api/Request?Data1={data}&Data2={data}

For POST Method:

http://localhost/<ApplicationName>/api/Request

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s