Things hard and not so hard.... RSS 2.0
# Tuesday, February 19, 2013

“Ding ding” after spending 4 rounds(hours) in the ring with this guy, I’m taking the gloves off and heading for the showers and salts.

I’m in the middle of some BizTalk work (which is nice for a change) and I’m ticking my tasks off.

I’ve got a REST receive port exposed from BizTalk via IIS and published through the WCF Publishing Wizard.

image

(there’s Operations mappings and extracting variables from the URL to Context Properties under the Configure – omitted for brevity)

Couple of shots of the WCF Service Publishing Wizard:

image

image

The issue here is that – once the Wizard completes you’ll get:

http://<servername>/coreapi/customer/Service1.svc as the URL to call.

The task was simple:

I wanted to call URLs such as

http://<servername>/coreapi/customer/123456789/enquire

http://<servername>/coreapi/customer/123456789/verify

etc. 

And not their equivalents of:

http://<servername>/coreapi/customer/Service1.svc/123456789/enquire

 

The Solution was to use IIS URL Rewrite which looks to be the Swiss Army knife that MacGuyver uses.. (but he only needs a paperclip to take out an entire train).

Lots of samples and numerous examples of solutions that work and people are high-fiving in about 5 mins of starting…alas not for me Sad smile. The other point to note here also is that a URL Rewrite module exists for:

  • Default Web Site
  • Each IIS Application under the Root Website.

I wanted to keep things confined to just my IIS Application and not have to have requirements of changing the Default Web Site for instance.

The tricky part was to find out how IIS works and it’s matching.

image

Underneath CoreApi I have Customer as an Application as in

/coreapi/customer

**The part that URL Rewrite appears to do** (that floored me for a while)

It chunks the FULL REQUEST and passes just the part required to your app.

So take the full URL:

http://localhost/coreapi/customer/1234234/enquire

As you traverse down the IIS ‘Application tree’ the URL that is passed to each URL Rewrite in each underlying IIS Application is *different*, as in:

  • /coreapi = ‘customer/1234234/enquire’
  • /coreapi/customer = ‘1234234/enquire’

This was possibly the hardest piece to figure out. I’d setup failed request tracing in IIS and those logs, while I feel like I’m walking into the Engineering room of the century with all the logs, pages and info… I wasn’t seeing ‘URL Rewrite failed to apply your rule because …..’  - it just wasn’t appearing plain and simple.

URL Rewrite – the rules that won the show

  1. Under /coreapi/customer in IIS Manager
  2. Started off with a Blank Rule and setup the following:
    1. image
    2. image

So the RegEx Rule (at this level) simply states – if the Request begins with a number, then prepend ‘Service1.svc/’ to it.

The key is knowing what the URL being passed to URL Rewrite is at this level in the IIS Application/vdir tree.

What the web.config says at this level:

<rewrite>
           <rules>
               <rule name="CoreApi Rule" patternSyntax="ECMAScript">
                   <match url="([0-9].*)" />
                   <action type="Rewrite" url="Service1.svc/{R:1}" appendQueryString="false" logRewrittenUrl="true" />
               </rule>
           </rules>
       </rewrite>

I hope I’ve saved you a bit of time on your next endeavour.

Tuesday, February 19, 2013 4:12:33 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
BizTalk | BizTalk 2013 | Tips
Archive
<February 2013>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
242526272812
3456789
Blogroll
 AppFabric CAT
AppFabric Windows Server Customer Advisory Team - New Blog.
[Feed] BizTalk 2006 - Windows SharePoint Services adapter
BizTalk 2006 Sharepoint adapter!!
 Breeze SharePoint 2010 Bootcamp
Breeze SharePoint 2010 Bootcamp
[Feed] BTS 2006 R2/EDI
[Feed] Chris Vidotto (MS BTS Legend)
Needs no intro....
 Mark Daunt
BTS/SPS/.NET GURU!!!
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2014
Breeze
Sign In
Statistics
Total Posts: 605
This Year: 9
This Month: 2
This Week: 0
Comments: 270
All Content © 2014, Breeze