How to consume rest service in WCF that was generated with NetBeans? - c#

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 !

Related

How to Create/Manage a WCF Project in a VS2013 App Using WPF anf MVVM pattern

I have fiew question about the WCF Service Library. I'm using Visual Studio 2013 WPF and the MVVM Pattern.
So in my Solution I have multiple projects and 1 of em is the WCF Service Library. In my Library I have a Service for Users
my Questions are :
Is it Better to separate the WCF Service Library in an another Solution ?
Where should I create my UserModel ? (Right now it's in my User Project not the Service Library)
How should I reference my Service in my Projects
Where and How should I store my SQL DB Connection String, how should I wrap the sensitive data like the Password ?
Should my Services be placed on the Server ?
Also, If you have any good Tutorials for WPF MVVM WCF Services that would greatly help.
Thanks all
Yes: I would create a separate WCF application and run that in parrellel with your WPF app.
I'm not sure what a user model is.
You add a service reference to your exe or class library. In there, you specify the endpoint address.
Consider using Entity Framework as well.
Yes or a Windows Service

Exchange Server 2010 not able to use ExchangeServiceBinding proxy class in Visual studio 2010

Presently I am working on application that needs to fetch data from Exchange server 2010. If I add Service reference in Visual studio 2010 using url "https://mail.test.com/ews/exchange.asmx", the service reference is generating "ExchangeServiceBinding" When I look from browser. But I am not able to use it as object. How to proceed with this? And since I am doing this in windows 8 metro and Wp7, I am not able to use managed api dll. Please help me guys.
As far as I know, you are not able to do that in Windows Phone 7. You need to create a proxy web service that can connect to Exchange and then use that service as a REST endpoint.
Check out the tutorials by Telerik on how to do that, they needed it for their Tasks application.
You can use raw soap calls.
Here are good links to get started
http://blogs.msdn.com/b/emeamsgdev/archive/2011/09/13/soap-test-application.aspx
http://msdn.microsoft.com/en-us/library/cc500285.aspx

Testing a WCF web service

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.

why do we need SvcUtil.exe to create /generate proxy class

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.

Programming against WSDL without access to actual webservice

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

Categories