Greetings!!
I am new to wcf and have some doubts.
I am able to create one wcf service and also able to consume that service in a client application using "add service reference".. now my question is why do we need SvcUtil.exe to create /generate proxy class and then consumed by client, the same thing can be done using 'Add ref' easily. What is the exact purpose.
You don't - I'm fairly sure they're equivalent. Obviously svcutil can be run from the command line whereas 'Add Web Reference' only works in Visual Studio but they do roughly the same thing.
We use svcutil not add web reference because the huge raft of files it creates became a version control nightmare.
Related
May i know is there a way to add c# service reference into a react native project?
Thanks
Well, finally I added a new Web API layer to communicate with the service reference. Seems like that is only way to communicate with service reference.
Recently I found another solution that writing a SOAP function in a node.js. You can simply run npm install soap in your node.js and follow the soap documentation and it works like charm. This method can save a lot of time compare with the C# Web Service method.
I have a lot of SOAP/XML and REST/JSON experience in Java and C++, but am pretty much a newbie in .NET. I have to create a SOAP client from a WSDL in C# in VS 2012. The app is not a web-based app, but a console app that will be run as a cron job every 24 hours. It has to query a Web Service for a token, do a client database lookup, and then use the token to update a list of client id's on the Web Service with any new ones - two calls only.
The company has a tester where I can type in either SOAP message (envelope and contents) by hand, click the run button, and a window shows the correct response in its SOAP envelope. My only confusion would seem to be endpoint-related. A WSDL-generated client should take care of everything.
I don't know much about C# (5), the .NET framework (4.5.x), or the newer .NET versions of VS (I've been using Eclipse, IntelliJ IDEA, and even jEdit for the past decade and more).
I've seen a dozen different "solutions" to this problem, ranging from WSDL.EXE and SiteUtil.Exe through adding the WSDL file as a (web?) reference or using one of the NuGet addons. The problem is that every solution I've found appears to asssume the client app is built on one of the web templates. I have to do this as a background .exe in plain C# without any web-based support or interaction in my app.
Any suggestions on the best (hopefully simplest) way to generate client source code?
You are not alone in being confused. You have to realize classic SOAP (asmx/wsdl) is considered an "outdated" technology (by Microsoft), so these days it hidden away in the toolset in favor of newer technologies. The most basic approach is to add it as a Reference from the solution explorer within Visual Studio itself. Here is a step-by-step:
Create a console application
In the solution explorer, right-click the References node and choose Add Service Reference
Ignore most of the dialog that comes up, and go straight for Advanced:
From the bottom of the Service Reference Setttings, choose Add Web Reference...
Now fill in the location of your ASMX, hit the little arrow, wait a bit for the tooling to discover the service, then hit Add Reference
This will add a Web Reference to your project that you can then use to access the methods of the webservice.
[Edit] (to answer your question)
If you have a .WSDL file on disk, you simply enter the file location on disk in the URL box of the Add Web Reference dialog:
In that case, the generated service has a default namespace of WebReference (unless you change it, of course), and you'll most likely want to explicitly set the URL:
var service = new WebReference.GlobalWeather {Url = "http://www.webservicex.net/globalweather.asmx"};
var weather = service.GetWeather("Amsterdam", "Netherlands");
Console.WriteLine(weather);
I've created a rest service from a mysql database with NetBeans and I want to consume the service in C#, with WCF if possible.
Is there a decent way to generate entities from the WADL file that I can use in Visual Studio and call the rest service methods?
What is the best way to consume the rest service created with NetBeans using Microsoft technology ?
It would have been nice if I could do the same with the WADL as with the WSDL in Visual Studio, to add a service reference...
I've found a tool called WADL.exe for generating entities for c# from the WADL file but it didn't work.
Please help !
I have written a commercial WCF web service.
I would like to give the service to another person to test independent of the application that will be using the web service. This is because a third party is going to be building that app and we don't have access to it at the moment.
Another thing to remember too is that the person I want to hand this off to for testing is a non programmer. That is important.
So are there any tools out there that can subscribe to a WCF web service, and recognise what data needs to be inserted, and create a GUI to try out different combinations of data?
Thanks.
I typically use SoapUI for that purpose. You can also create test suits with it and it's free. Alternatively you can use the Microsoft WcfTestClient.exe that comes with Visual Studio since version 2008 I guess...
WCF Test Client (WcfTestClient.exe)
You can find the WCF Test Client (WcfTestClient.exe) in the following location: **C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE**
Using the WCFTestClient Tool to Test Service Operations
You can consume a web service with Office InfoPath, or write a simple test application in C#.
In general, you need to publish the web service meta data (normally as a wsdl end point) - this metadata should enable any client to get all the information needed to make calls to your web service.
This may help: http://msdn.microsoft.com/en-us/library/ms734765.aspx
As may this: http://keithelder.net/blog/archive/2008/01/17/Exposing-a-WCF-Service-With-Multiple-Bindings-and-Endpoints.aspx
Update:
From the comment, is appears that you need non programmers to be able to test your service and are looking for a user interface that can be used to work directly with your web service (and automatically adapt to changes). As far as I know, there is nothing built it that will do this for you (though the old asmx services created web forms that could be used).
So you are looking for application that will create UI for manual testing of your service? Not sure if something like that is available for free. SoapUI PRO is able to do that but in contrast to common SoapUI it is not free. Basic SoapUI version requires tester to write XML messages directly.
You should think about your requirement. You want tester without any programming knowledge to test artificat which is for programmers - not for end users. You probably have to buy some tool or write your own solution to support such test.
I'm going to use C# to read data from a few webservices. I've done that many times before, but those times I've had direct access to the webservices from my development machine.
In this project I've just been sent a .wsdl file, and a couple of .xsd files for the webservice they have in their local intranet.
I've seen that I can use "Add Web Reference", and point directly to the .wsdl file, so that a C# class is created.
But how can I really test it? I'd like to return some dummy data that I can visualize while I develop. Any tips for this situation?
Mock Webservice
From the above source, a .cs file can be generated by opening a Visual Studio Command Prompt and running something like the following:
wsdl /language:CS /namespace:Your.Namespace.Here
/out:Directory\To\Save\To\ /protocol:SOAP /serverinterface
finally-your-wsdl-file-here.wsdl
You can also try SOAP UI for mocking up service with ease. (Free web service testing tool)
Check:
http://www.soapui.org/gettingstarted/mocking.html
The svcutil.exe tool bundled with the Windows SDK (found at C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin) is a nice command line tool that generates WCF client proxies. I've found this to be a good way to interrogate a WSDL. It'll create an interface for the service and then a proxy class that implements that interface. You can then mock up something else that implements that interface to facilitate testing.
It is easy to create your own server side stub. Assuming you want to do it with WCF, then go here. You can then add some basic logic to get your client working.
You can also use the legacy Web Service functionality via the WSDL tool's /Server option, though I recommend you use WCF.
You may also want to try a product like "Fiddler" (http://www.fiddler2.com)
It allows you to capture HTTP (or HTTPS) packets and send a fake automated reply file back as if the server had sent the response. I use it for my project and it works wonders when the test server goes offline (which is often). I take an old response packet, save it as a text file, then send it back again and the application I'm building has no idea it didn't come from the actual host.
I've also found this article very useful: https://ivangrigoryev.com/en/how-to-mock-a-web-service-in-dot-net/
It describes the steps needed, from downloading the WSDL file and to the creation of the test project:
Get WSDL somehow
In the VS Command Prompt:
wsdl /language:CS /out:C:\Downloads\ /protocol:SOAP /serverinterface C:\Downloads\webservice.wsdl
Create a new ASP .NET Web Application with an empty template
Add the file, generated on step 2, to the project
Add a new service to the project (Add -> New item -> Web Service (ASMX))
Change the class definition in the code for this added web service, so it implements the right interface, e.g replace System.Web.Services.WebService with yours.
Hit Alt+Enter and implement the interface automatically with stubs.
Hit F5, the service will run and your browser will open, copy the URL and use it instead of the real URL.
This works only in .Net Framework since .Net Core and .Net 5 dropped the WCF server support. But I found it acceptable to have the main project on .Net 5, but this mock service on .Net Fw 4.8