for a project we need to call some webservices from vbscript. This is doable, but it requires building the entire XML fragment by hand. I’m spoiled by .NET so I want to do it better.
There is the option of building a COM component and calling that from vbscript, but unfortunately that also requires registering the COM component on the client, an option we don’t have.
Another thing I thought of is building a console application which handles the webservice calls and exceptions and things. Problem here is that I need to return a string to the vbcode, where a consoleapp can only return an exit code and nothing more (as far as I know). Since it’s a shared scenario, I can’t write to a textfile either since that will cause problems in multiuser scenario’s.
So I wondered if there are any options I missed and should consider? Or in the other case: what option would you guys pick and why?
Edit: worth mentioning; the webservice is mine and so is the server on which it runs. It will be secured with SSL and authorization to make sure no one other than our clients can use it. I set it up as a WCF service, but it’s to be constructed so I can still change that (either the service type or the bindingtype).
The answer would really depend on your exact scenario. For example if you have control over the web service you could expose a
netTcpBindingendpoint and then consume it directly from vbscript.Here’s a nice article which shows how to achieve this step by step. Basically your client code might look like that:
The WCF service could either be hosted in WAS in IIS 7.0+ which allows to use
netTcpBindingor be self hosted as a Windows Service for example.Another possibility if you have control over the service is to expose it as a REST which is easier to consume. You could opt for JSON and XML which might still require parsing on the client but at least it will make things cleaner.
And if you are tied to SOAP then the recommended approach is to use the
MSXML2.ServerXMLHTTP.6.0as shown in this answer and build the envelopes manually.The
MSSOAP.soapClientcontrol that shipped with Windows XP is now obsolete even if it allowed to achieve exactly what you were looking for with a SOAP service.