tags:

views:

264

answers:

2

I have a WCF Service that I want my client to be able to consume from IIS without going through a proxy. The client was consuming asmx service in vbscript using the htc behavior:

<div id="oWSInterop" style="behavior:url(webservice.htc)"></div>

oWSInterop.useService "http://localhost/WSInteroperability.asmx", "WSInteroperability"

Set response = oWSInterop.WSInteroperability.callServiceSync("BuildSingleDoc", 1002, 19499, XMLEncode(sAdditionalDetail))

So basically I just want to make this work with making as few changes as possible on the existing client. Am I forced to use a proxy (that is, a class on the client side that exposes the operations in the WCF service) when consuming a WCF service? I do understand the benefits of a proxy and am not opposed to using it for most other client implementations, but in this case I'm not sure I have the time to deal with it on the client - i just want it to work the way it has been with only the endpoint changing.

A: 

What are you seeing? What makes you thank that proxy is an issue? If that is server-side code, it should use the browsers settings (WinINet) which should work fine. Perhaps the "localhost" would be an issue, though, since to the client that still means "talk to yourself" (i.e. not the server).

If that is server side you'll probably need to configure WinHTTP appropriately; in particular, to skip the proxy for local addresses. Of course, "localhost" should loop-back anyway...

Marc Gravell
it's client side code - can't make this call from code behind. I get "Invalid active port" when I try to call the service same as it was calling the asmx.
Tone
+1  A: 

A client-side proxy class to call the service?

Yes, you definitely need that (unless you do REST-based WCF services, which you can call with a HttpClient alone) - that's where the whole WCF runtime lives and does its magic.

If you want to call up REST-based services, you can do this without any proxy whatsoever - but then you're left to do XML or JSON parsing yourself. It can be done, but it might not be such a great idea.

What's the problem with the proxy?? It's really just a small wrapper that bundles up your calls into a serialized message and sends it to the server side. No big harm, in my opinion....

marc_s
Not quite *definitely*. You can invoke services without a proxy class, but you have to construct messages "manually" and you need to unwrap responses similarly. It's possible to do, but not pleasant, and in general not recommended unless you need extreme flexibility.
Cheeso
@cheeso: ok, you're right - in **theory**, one could probably call a WCF service without a client-side proxy. But that's quite "esoteric", I'd say - not very likely and not very easy to do....
marc_s
don't think i want to go rest here - since the existing calls were asmx, and thus soap based I want to keep using that same format.
Tone
I agree - it is much more difficult to invoke a WCF service (or any SOAP-based Web service) without using the tool-generated proxy class. But possible! See **Calling WCF Service from VBScript** http://stackoverflow.com/questions/944975/calling-wcf-service-by-vbscript
Cheeso
@Cheeso: Sweet I'll check out that code sample in the other post and see if I can get it working calling from vbscript. One of the requirements is exactly that - to make the calls from the (browser) client and not from server side code.
Tone
To help out with that, I'd suggest getting a network trace of the messages generated using the WCF proxy. Maybe with a tool like Fiddler. http://www.fiddler2.com . Then try to reproduce that message format in the VBScript "manual" method. This is also possible of course in Javascript - you'd need to do the translation of that VBScript code into JS on your own.
Cheeso
I have fiddler running, got my message and have reconstructed it, but still getting http 400 Bad Request back. Maybe I just missed something with the formatting - any ideas?
Tone