tags:

views:

168

answers:

2

Hi,

I am creating a WCF Service with a method

[OperationContract]
[WebGet(UriTemplate = "acl/f={fullFileName}")]
string GetACL(string fullFileName);

fullFileName is a full path to a network file, or a file on the host.

The host is a Windows Service with webHttpBinding and behavior configuration. I want to call this from a browser using something like

http://localhost/webservice/acl/f=[my network path here]

I have tried .../acl/f=file://\server\share\file.ext .../acl/f=file://c:\file.ext

In the browser I receive "Endpoint not found".

I know this works because I can call .../acl/f=file.txt and I get back the proper response from my service indicating that the file was not found. So the method is getting called correctly when I don't use slashes of anysort in the URI.

Any thoughts on this will be greatly appreciated.

Thanks, beezlerco at hotmail...

A: 

You need to encode the slashes, colons, and technically the periods as well.

  • \ should be %5C
  • / should be %2F
  • . should be %2E
  • : should be %3A

for most other special characters see http://www.asciitable.com/ and use '%' plus the hex column on that table.

TJMonk15
A: 

I believe HttpUtility.UrlEncode is what you are looking for.
(For a detailed description, see Using HttpUtility.UrlEncode to Encode your QueryStrings)

kloffy
Hi Scott Smith - Yes, this is a webget. I am trying to call this method from the address bar of my browser. I am trying to enter http://localhost:port/webservice/acl/f=???Not sure what is appropriate for ???
Beezler
Hi Isaac Cambron, yes I've tried encoding them %2f and %5c. The brownser substitutes the appropriate slash when it fails to make the webservice call.Thanks,
Beezler
I assumed that you were generating the URL programmatically in C#. The method I posted encodes a string so that it is safe to pass it as a parameter via get. The counterpart of this method is HttpUtility.UrlDecode, you can use it to reconstruct the original string. If you are entering the URLs by hand, you're going to have to make the appropriate replacements by hand.
kloffy
I changed the URI to http://localhost/webservice/acl?f=... the ? solved the problem.
Beezler