I want to connect LinqPad to a WCF web service which exposes its WSDL information at a URI of the form http://server.example.com/Product/Service/Version/Soap11?wsdl
. I can successfully add this URI as a Visual Studio WCF web service reference, and it works with WcfTestClient also.
The actual endpoint of the service, when connecting to invoke methods, is http://server.example.com/Product/Service/Soap11
.
When I try to add the web service as a LinqPad connection, if I specify the web service's URI including the ?wsdl
query, I get a LinqPad error message saying "ArgumentException: Expected an absolute, well formed http URL without a query or fragment. Parameter name: serviceRoot". If I leave out the ?wsdl
query, I get a 400 Bad Request
response instead.
(I get the same 400 Bad Request
response when I try to create a Visual Studio web service reference, or add the service to WcfTestClient, without appending ?wsdl
to the URI).
Is there anything I can change at the client end to get LinqPad to successfully connect to this web service? Or do I need to mess around with the configuration at the server end? I don't control the web services I'm trying to connect to, but I might be able to tweak some configuration files on the server if I must.
Check out the following:
https://github.com/dylanmei/linqpad-soap-driver
It's a third-party LINQPad driver for SOAP-based web services.
It looks like I misinterpreted the scope of LINQPad's "Add connection" feature. It's for WCF Data Services only (which implement the OData specification), not for WCF web services in general. (The difference between WCF services in general and WCF Data Services specifically wasn't previously clear to me).
The services I'm trying to connect to are WCF web services, but aren't WCF Data Service web services. It turns out that the correct way for me to consume those web services from LINQPad is to generate a proxy class code & configuration file using svcutil.exe, which can then be compiled through VS or csc.exe, and the resulting assembly is then added as a standard assembly reference in LINQPad. The proxy classes can then be used in LINQPad the same way that they are used in Visual Studio.
I'll offer an alternative answer which will help if you're targeting a service that uses authentication. In my case the service uses Windows Auth which the linqpad soap driver does not yet support. You'll be generating the client code using svcutil.exe
, compiling it to an assembly, and then creating a Linqpad query to use it.
Generate your service client & config file with svcutil.exe http://mylocalsite/myservice.svc
- it should produce a myservice.cs
file and output.config
.
Compile the client code into an assembly: csc myservice.cs /target:library
. You should now have myservice.dll
.
Create your linqpad query and go into its properties (F4). In the App.config tab set the Custom Path to the your output.config
file. Under Additional References, add a reference to myservice.dll
.
Your query will be very simple, something like:
var client = new MyServiceClient("BasicHttpBinding_IMyService");
var result = client.DoTheThing();
result.Dump();
client.Close();
LinqPad will likely prompt you to add a reference to System.Web.Services
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With