1

I've just recently built a Silverlight application that communicates with a server via WCF. The data we communicate back and forth has been seamless and to be honest, quite easy to implement (w/ SL). Unfortunately, I need the ability to request this same information from the WCF similarly to that of an ASMX web service. Right now, I'm running the service locally (http://localhost/aps.svc) but I'm not able to "Invoke" any of the methods via a web browser (similar to a asmx web service). For example: http://FooBar/Service/servic.aspx?op=GetName would return a name. I need this ability, as our 3rd party software is limited to using web asmx services and I would like to use the WCF already built.

I'm fairly new to WCF and web services in general - so any help would be greatly appreciated!

-Tom

arctek
  • 219
  • 1
  • 16

3 Answers3

2

In order to use your WCF service directly in the browser, you need to switch to a REST-style WCF service.

See the WCF REST Developer Center for a great deal of information on WCF and REST.

Basically, with WCF REST, you can "address" everything in your domain as resources; REST is resource-oriented, while SOAP / ASMX is operation-oriented.

So you probably wouldn't have something like op=GetName in your method, but rather something like:

http://yourserver/YourWCFRESTService.svc/SomeObjectOrResource/Name

and this would return the name "object" of that object or resource, as an XML or JSON stream of data.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
1

As marc_s mentioned, if you convert or have REST as one endpoint then you may get it to work.

    [OperationContract(Name = "RetrieveUser")]
    [WebGet(ResponseFormat = WebMessageFormat.Xml, UriTemplate = "/{op}")]
    public System.IO.Stream RetrieveUser(String op) { ... }

This may enable you get the operator and then respond correctly.

What I did is to have a controller where the work is done, and my SOAP and REST services just handle getting requests and sending back in the correct format.

James Black
  • 41,583
  • 10
  • 86
  • 166
  • Thanks James - I'm going to give these a try this afternoon. I'll let you know how it goes. – arctek Oct 14 '10 at 18:24
0

similar to this and this. in short, i don't think it can be done.

Community
  • 1
  • 1
vlad
  • 4,748
  • 2
  • 30
  • 36