WCF (svc files) Has anyone gotten them to work?

Oct 14, 2009 at 10:32 PM

I've setup a basic RewriteRule:

RewriteRule ^/(.*)$          http://bt01v:53/ticket/$1 [P]

And this works when I try to go to Default.aspx  but when I try Ticket.svc I get the "The resource cannot be found." 404 page..

Is there a difference between ASPX and SVC files?  can a WFC Service not be used with this reverse proxy?

I think my head may explode soon trying to figure this out..

thanks,

dan.

 

Oct 14, 2009 at 11:02 PM

To add onto this, I've checked the event monitor and it displays:

 

 

WebHost failed to process a request.
 Sender Information: System.ServiceModel.Activation.HostedHttpRequestAsyncResult/32347029
 Exception: System.Web.HttpException: The service '/BMO_Ticket.svc' does not exist. ---> System.ServiceModel.EndpointNotFoundException: The service '/BMO_Ticket.svc' does not exist.
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
   --- End of inner exception stack trace ---
   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
 Process Name: w3wp
 Process ID: 1464

WebHost failed to process a request.

 Sender Information: System.ServiceModel.Activation.HostedHttpRequestAsyncResult/32347029

 Exception: System.Web.HttpException: The service '/BMO_Ticket.svc' does not exist. ---> System.ServiceModel.EndpointNotFoundException: The service '/BMO_Ticket.svc' does not exist.

   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)

   at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)

   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()

   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()

   --- End of inner exception stack trace ---

   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)

   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)

 Process Name: w3wp

 Process ID: 1464

 

Coordinator
Oct 15, 2009 at 2:50 PM

It sounds like you are requesting BMO_Ticket.svc instead of Ticket.svc as you mentioned before.

Oct 15, 2009 at 2:53 PM

I just said Ticket.svc as a general filename..

I really meant BMO_Ticket.svc  and it wasn't working..

You can try it with my hello world example and see if you can get it working:

http://setlist.ca/userfiles/temp/test.rar

because I know I tried EVERYTHING..

Oct 15, 2009 at 3:00 PM

BTW.. I called microsoft.. and they think it's this url rewiter that's not working..

They suggested that I use windows 2008 with IIS 7 instead to rewrite my URLs instead..  :S

Coordinator
Oct 15, 2009 at 3:37 PM

I looked at your web.config file, it looks like you haven't included any of the necessary configuration items to get the proxy working. Please make sure you follow the ReadMe.txt file

 

Also do you want to rewrite your URL's or proxy them?  Because as far as I know IIS 7 doesn't include a reverse proxy.  Also lets try something. 

 

What happens when you call, from the server?

http://bt01v:53/ticket/BMO_Ticket.svc

 

Nick

Oct 15, 2009 at 3:44 PM

my ManagedFusion.Rewriter.txt is:

 

RewriteEngine On
RewriteLog "C:\Inetpub\wwwroot\WCFRedirect\log.txt"
RewriteLogLevel 9
# redirect to another server based upon the domain name
RewriteRule ^/(.*)$          http://bt01v:53/$1 [P]

RewriteEngine On

RewriteRule ^/(.*)$          http://bt01v:53/$1 [P]

 

And yes.. locally http://bt01v:53/ticket/BMO_Ticket.svc works.. as does calling it by the IP.  What also works is if I put Default.aspx in that directory and then call that externally (http://ticket.company.com/ticket/Default.aspx) so do I need to configure it differently if I'm calling a svc file as opposed to a aspx file?

Both those files are in the same directory, and both of them work internally.. but only the aspx works externally..  :S

 

And apparently Microsoft has written a module for IIS 7:

http://learn.iis.net/page.aspx/659/reverse-proxy-with-url-rewrite-v2-and-application-request-routing/

 

Coordinator
Oct 15, 2009 at 4:14 PM

Please read the ReadMe.txt fully, I think you are forgetting the sections in the Web.config which are critical.

Oct 15, 2009 at 4:24 PM

I assure you, I have read the readme.txt file fully.  According to the readme.txt I had to (and I completed):

1: Add the items to the config file.  You can see my config file here: http://setlist.ca/userfiles/temp/web.rar

2. Add the files to the BIN directory. (Well this obviously is done correctly as Default.aspx would not work if I didn't do this)

3. Create a Files file named ManagedFusion.Rewriter.txt. This is also done correctly as I can tell since the ASPX file works.

4. Enable Wildcard rules.  I'm not really sure what this does, but I did follow these instructions to the letter.

 

Are you saying that you got that hello world example to work externally?  can I see the web.config file and Rewriter.txt you used?

Coordinator
Oct 15, 2009 at 5:52 PM
Edited Oct 15, 2009 at 5:53 PM

I had the exact same web.config as you just sent.  From the examples:

 

I was able to get the Service.svc to work through a proxy.  Lets try a couple of basics first, before we start getting in to weird issues, such as why your port that you mentioned above is the standard DNS port as opposed to the standard HTTP ports such as 80 or 8080.

 

Make you rules file look like this:

RewriteEngine On

RewriteLog "log.txt"
RewriteLogLevel 9

RewriteRule ^/(.*)$          http://bt01v:53/$1 [P]

 

This will log every request that goes through the rewriter, and should help to give us a better understanding of why the proxy is not working.

Oct 15, 2009 at 6:11 PM

First I had to use port 53 for testing.. as the person who set up the server closed all the incoming ports..  if I was to use this in production, then yes, I would have him open up 8081 for me..

For this next test.. I had to used Localhost for the machine that has the url-rewriter because someone changed the external address on me.. but whatever it still gets the same result.  I tried both service.svc and Default.aspx and only Default.aspx works.  Yet when I go to (http://bt01v:53/wcf/service.svc) it works..

log file results:

 

Rule Processing: RewriteLogLevel: 9
Rule Processing: RewriteRule: ^/(.*)$ http://bt01v:53/$1 [P]
Rule Processing: Managed Fusion Rewriter Version: 3.0.6.29098
**********************************************************************************
Rewrite: Input: http://localhost:53/wcf/service.svc
Rule 0: Input: /wcf/service.svc
Rule 0: Rule Pattern Matched
Rule 0: Output: http://bt01v:53/wcf/service.svc
Rewrite: Proxy: http://bt01v:53/wcf/service.svc
**********************************************************************************
Rewrite: Input: http://localhost:53/wcf/default.aspx
Rule 0: Input: /wcf/default.aspx
Rule 0: Rule Pattern Matched
Rule 0: Output: http://bt01v:53/wcf/default.aspx
Rewrite: Proxy: http://bt01v:53/wcf/default.aspx

Rule Processing: RewriteLogLevel: 9

Rule Processing: RewriteRule: ^/(.*)$ http://bt01v:53/$1 [P]

Rule Processing: Managed Fusion Rewriter Version: 3.0.6.29098

**********************************************************************************

Rewrite: Input: http://localhost:53/wcf/service.svc

Rule 0: Input: /wcf/service.svc

Rule 0: Rule Pattern Matched

Rule 0: Output: http://bt01v:53/wcf/service.svc

Rewrite: Proxy: http://bt01v:53/wcf/service.svc

**********************************************************************************

Rewrite: Input: http://localhost:53/wcf/default.aspx

Rule 0: Input: /wcf/default.aspx

Rule 0: Rule Pattern Matched

Rule 0: Output: http://bt01v:53/wcf/default.aspx

Rewrite: Proxy: http://bt01v:53/wcf/default.aspx

 

Coordinator
Oct 15, 2009 at 7:22 PM

Well the next thing we need to do to figure out why ASPX pages work and SVC pages don't is to record the information getting passed back and forth.  A good tool for this is called Fiddler.

http://www.fiddler2.com/Fiddler2/version.asp

It will record the outgoing and incoming responses that go in and out of your local machine.  To enable .NET to proxy it's requests through Fiddler replace the following in the web.config:

<system.net>
        <!-- defaultProxy enabled="true">
            <proxy proxyaddress="http://127.0.0.1:8888" />
        </defaultProxy -->
    </system.net>

With this

<system.net>
        <defaultProxy enabled="true">
            <proxy proxyaddress="http://127.0.0.1:8888" />
        </defaultProxy>
    </system.net>

And Record the data for the SVC and then save it and post it up for me to look at.

Oct 15, 2009 at 8:22 PM

strange thing.. fiddler adds a web session when I go to:

http://localhost:53/wcf/default.aspx

and

http://bt01v:53/wcf/service.svc

But not when I go to:

http://localhost:53/wcf/service.svc

It's like it's not going there at all..

Oct 15, 2009 at 8:24 PM

Just so you know, I tried going to:

http://localhost:53/wcf/default23.aspx

and a web session came up in red with an error icon (notifying that it can't be found)..

I did that test to see what it does if it can't find the file..  so it's not like it can't find it.. it's more like not looking for it..

Oct 16, 2009 at 8:04 PM

nberardi,

I appreciate you trying to help me get it working.. I ran out of time and had to setup a windows 2008 server with IIS 7.0.

I got it working very quickly, and if you havn't tried it, you should check it out.  It's very flexible and had tonnes of features.

Thanks again for everything,

dan.