I've been doing java web services for a couple of years here and there and I've always heard about the ease of use of C#.Net Soap-WS clients. I just tried it out and I have to say, I am a bit jealous - having had to fight through generated code with both Axis and CXF (try using Axis in OSGi or with NTLM authentication...or just look at the horrible generated code, or try using dynamic URL's in CXF).
Is there a java analog to the simplicity of .Net (soap) web service clients? Ideally, you would add the URL to your project, just like you add a service reference in Visual Studio and the behind the scenes code would be setup for you. Is this possible? If not, why not - what is C#.Net doing differently?
I've had good luck with the Spring Framework . Its not quite as easy as C#'s toolset, but when you get down to it, its all just reading a WSDL and generating client adapters. Visual studio lets you do that with the push of a button where with Spring, you can use Ant/Maven to generate your proxies/adapters. Most IDE's will do this for you too (see Randolpho's answer, I know IntelliJ Idea does).
Edit: I believe SoapUI will do this as well, although I haven't used it so I can't tell you how well that works
Eclipse will create a Java web service client very similar to a Service Reference.
http://www.eclipse.org/webtools/jst/components/ws/M3/tutorials/WebServiceClient.html
Related
I have a smart device (Windows CE 2013) that just got the requirement to be controlled from a number of different devices, to do this, we decided to serve a web page from the device that allows it to be controlled.
I've also read that compact framework doesn't support ASP.NET so I'm intending to serve a static webpage that contains a javascript application that calls web services hosted on the device.
I also found this link explaining how to serve a SOAP Service in C++, but it seems old, and I'd prefer to do this in C# as it's my preffered language and I already have some code on it
I'm not quite happy with this solution, am I missing something? Can't I really do this in C#?
You could try this library for .NET https://github.com/ServiceStack/ServiceStack .
It is a free in case if you are using branch v3 form a github.
There's nothing built-in in the CF that provides web server capability. Windows CE has always shipped with an HTTPD server, but, honestly, it sucks and can't be integrated with managed code anyway.
We solved this problem long ago by creating our own IIS-like web server implementation (available commercially). You could do something similar as well - it's just a lot of Socket work. That trivializes the complexity of concurrent request handling and providing an IIS-like object model, but you get the idea. Basically you have to write the whole thing.
The main answer to this is to use Mongoose (or the MIT-licenced equivalent Civetweb). They are C webservers designed for just your task - an embedded web server.
They are really easy to implement, 1 C source file added to your project, give it an array of options, and you're done. See the examples. It has plenty of features and is fast, and small (40kb compiled!). They say it takes 5 minutes to get going with it, and they're right - I tend to use it to add webserver functionality for normal applications now.
We have C# code, which is backend for us. Now we need it to be used in our website which is developed in Drupal.
As far as I know, there is no easy way to do it. You basically have 2 options:
Rewrite the code in php. It may be not possible to do it however, it depends on what the code does.
Expose c# code as an external webservice (e.g. with WCF) and then consume the webservice. Drupal is able to do it - more info.
A sloppy solution would also be to display your C# page in the Drupal page with an iframe. I do also agree with empi's answer to rewrite the code in php or a web service depending on your requirement.
You can build DLL project (class library) in C# and use the DLL as reference back in the drupal project.
Not sure about this, and never done before.
You better research more.
But, the best way to use the .NET code in another application is to build the required code into DLL project and use in whichever language you want to use.
I have an old MFC app written in Visual Studio 6. This will at some point be rewritten in C# .NET. However, before then I have to write a couple of new Windows services for the existing application. The others were written in ATL. What I would prefer to do is write these new services in C# .NET so that when the rest of the application is rewritten, these don't need to be.
Is it going to be possible to call the interfaces on the libraries hosted in a .NET windows service from the old application? If so, could you please explain how.
Absolutely. You're looking for a feature of .NET called COM-Interop.
http://msdn.microsoft.com/en-us/library/kew41ycz%28v=vs.71%29.aspx
http://msdn.microsoft.com/en-us/magazine/cc163494.aspx
The second link has an ATL example.
EDIT:
Based on your feedback in the comments, let me expand on this...
Ah - you're right about the sample on that page.
The first link is really where you want to start for all the details. If you follow the links, you'll find this page:
"Exposing .NET Framework Components to COM"
http://msdn.microsoft.com/en-us/library/zsfww439%28v=vs.71%29.aspx
Essentially, it's just a matter of applying a series of attributes to your classes and properties, and then generating the appropriate registry entries on the client machine (which .NET has a tool to do - see: http://msdn.microsoft.com/en-us/library/bctyca52%28v=vs.71%29.aspx)
I've done this several times myself for .NET projects people needed to call from VC++ and/or VB6.
Some other links that might be of interest:
http://www.codeproject.com/KB/COM/nettocom.aspx <-- Perfect example of what you're trying to do.
http://www.codeproject.com/KB/COM/Universal_CCW.aspx
I've done this exact thing with an MFC-based C++ application in Visual Studio 2008 and a .NET-based C# Windows service.
First, if you have not created the C# Windows services yet, I've got a couple of tutorials for creating the basic framework. The first tutorial provides a step-by-step procedure for creating the service and writing events to an application-specific event log. The second tutorial shows how to modify the service to install and uninstall itself from the command line, which I find of great use.
Second, you need to decide how you are going to communicate between your MFC application and your Windows service. Any kind of inter-process communication (IPC) model will work - sockets, pipes, shared memory, WCF, etc. Since you are wanting to migrate to .NET anyway, I would recommend using Windows Communication Foundation (WCF), which is the way I've done it. Specifically, I chose the named pipe aspect of WCF for my communication method based on the chart shown here.
If you go down the WCF route, you'll benefit from the fact that the communication between application and service is .NET-based. Thus, when you move your application to .NET, the communication mechanism won't have to be rewritten. The trick in the meantime is getting your MFC application to use the WCF code. To do this, write the WCF client code in a .NET assembly using C#. Then, use a C++ dll to bridge the gap between your MFC code and the .NET assembly. I've got another tutorial with step-by-step instructions for how to do this.
Hope this helps.
Yesterday I asked about what technology should I use to create dynamic web content here:
PHP, AJAX and Java
The suggested methods were JSP, JQuery, etc. But I thought maybe because I'm a .Net developer and I don't have any experience in web development but I have experience in WPF and C#, maybe I should go with Silverlight but the main problem here would be how can I communicate with the core part of my system which is implemented in Java?
So the main question would be: What is the best [and easiest to learn] method to send a piece of data to the Java part, get the result and use it in silverlight? A tutorial or simple example would be nice.
Thanks a lot in advance.
You should use Java Web Services as stated. Use WCF to invoke the Java WS by adding a Service Reference in Visual Studio by its url, then use the proxy classes generated automatically (located in Reference.cs) to invoke the WS. This is easy but remember SilverLight WS invocations are always asynchronous, so you must cath the OnCompleted event to get the results of the invocation. WS are slow but if the machines are in the same LAN, invocation could take a few milliseconds.
I think pipes are not your solution as SilverLight executes in a Sandbox and have many restrictions on what you can do.
This will depend on many factors, however a relatively easy approach would be to use Java Web Services. On the .NET side, WSDL will be picked up and transformed into proxy class by WSDL.exe from the Windows SDK. If, however, these two systems are on the same server (and intend on staying this way), you may decide to use pipes.
We've got some problems with an external company trying in integrate into a WCF service we expose and they are a Java shop. I was wondering if there are more than one toolkit that they can try to solve their issues and would like a list to suggest to them but I'm not familiar with the Java world at all.
Essentially they've got some memory leak (apparently!) but they are very sketchy in the details.
Microsoft and Sun worked together to ensure that their latest web services toolkits worked with each other. Sun's java implementation is Metro.
Are they using Axis, if you are presenting a standard webservice to them? Or are you presenting a custom REST service that they have had to do more manual coding for (HTTPClient, XML generators/parsers, etc)?
You need to ensure you're using a normal web service binding and nothing else. I admit though over the years getting java and .net web services to play nicely is no mean feat. A memory leak by the way, would have nothing to do with calling your web service and everything to do with the way the external company is managing their memory. You're not executing anything on their servers after all :-)
I've done this successfully with Axis. It was actually pretty straight forward, using the Eclipse plugins.