How to integrate WCF and SOAP to existing server-client application? - c#

I am new to server-client applications.
I am trying to build a prototype where a Java server communicates with a .net WPF client over http. The server and client currently communicate over a third-party messaging system(Tibco). I have done a bit of research and have decided on using SOAP and WCF. I have been trying to find tutorials on how to implement this but cant seem to find anything that fits my need. If anyone could point me to some resource that a newbie like me could use to come up to speed with implementing SOAP and WCF to existing system I'd really appreciate it. Also if anyone has any suggestion on any other protocol that could be used, feel free to recommend it.

We did this at work to support some 3rd party interop scenarios and our process looked like:
Generate a WSDL for our WCF service via the wsdl.exe tool (we defined a basic HTTP version of our services because of the lack of eventing in Java),
Used an apache CXF tool, wsdl2java, to generate Java classes for the WSDL,
Used the autogen'd client definition as a wrapper to perform calls on the server.
I'd imagine in your case you'd do the exact opposite, using java2ws.exe in the Apache CXF framework to create your WSDL, then using wsdl.exe in the .Net framework to generate your c# classes (or other CLI classes...), then consuming those classes to accomplish whatever it is you have a client do.
Here's the API page for the CXF Java->WSDL tool - http://cxf.apache.org/docs/java-to-ws.html
And for the WSDL.exe .Net tool - http://msdn.microsoft.com/en-us/library/7h3ystb6(v=vs.71).aspx

Related

Generate WSDL / SOAP specification from C# Interface as client?

Here's my situation: I'm writing a SOAP client using WCF. I am going to invite 3rd parties to develop services that my client can consume. This is kind of backwards from the norm, I think. As the client develper, I'm creating the specification, and the server developers are following it.
When it's the other way around, and the server developer is using C#/.NET, the process would go something like:
1) Service developer creates C# interface, a service type that implements it, and a host to serve it.
2) Service developer uses its server to generate WSDL and provides it to client developer.
3) Client developer uses WSDL document to generate a proxy and uses the proxy to consume the service.
However, I'm completely at a loss as to how to do this in reverse. So far, the only thing I've been able to thing of is to do step 1 as a mock, generate the WSDL for my mock, and provide it to the service developer. I'd prefer not to have to go through the work of doing this. Plus, I'm not sure how feasible it is for the service developer to generate a service based on a a WSDL document, especially since the service developers would probably not be using .NET. They could be using any number of SOAP frameworks and languages. I'm afraid that their service implementations would end up differing enough that my client application wouldn't be compatible with all of them at the same time.
I want this to be as easy as possible for the service developers, to encourage them to write them, but I want to have a single client, without having to modify my client code for each server.
I'm not really familiar with SOAP frameworks, other than WCF, so I don't really know how much is the same/different from WCF implementation.
Ideally, I'd like to just provide them with the C# interfaces, or run them through some tool that would generate information that they can use to implement their services in their language/framework of choice, and perfectly implement my specification.
What would be the best way to accomplish this?

Forbidden XML Schema constructs in WSDL of a web service

I am a Java developer who has created a rather big Web service that works nice with Java clients or other tools (Soap UI).
One of our clients wants to write a .NET client for the web service and uses the "add service reference" feature of VS2010. According to the client this does not work since our WSDL and XSD files use "Forbidden XML constructs" as defined in this article:
The problem is that we have made heavy usage of xsd:attribute data in WSDL.
So the question is:
Is there a workaround to make .NET stub generation code compliant with WSDL/XSD files that contain xsd:attribute? Is there another .NET library for webservices that supports this feature?
Another question of mine would be why does Microsoft impose these limitations in the first place? Why xsd:attribute is a forbidden costruct in a web service??? Any clues on that?
Probably related: C#.NET Generating web service reference using WSDL (from XML schema) problem
If you have access to a machine with the .NET Framework on it why don't you use svcutil to generate a proxy/config settings for him and send it to him?
See www.svcutil.com for the list of switches and options that are available to you
I have found that if the customer cannot do it one way and you provide a documented (possibly automated) way of doing things then that will generally suffice.
I have tested the HelloWorld.wsdl supplied in the link with the .NET version of Remobjects (http://www.remobjects.com) and it seemed to work fine. I don't have an actual service to test this with but I would suggest that you (or the client :) ) download it and give it a try.
The .NET version can be found here:
http://www.remobjects.com/ro/net.aspx
Apparently the answer is that you should NOT use the modern way of generating stubs with svcutil.exe and instead use the legacy way with wsdl.exe
Creating stubs from the command line with wsdl.exe works fine. The resulting code works as expected and the .NET client connects to the Axis2 Web service.

Web service written in both WCF and Java

Can I write a web service that implements the same methods and returns the same custom objects using both C#/WCF and also Java Web Services? And if so, can I then access the web services using a single web reference but with different addresses?
I'm asking because I have to host a web service that has a GetCitations and GetTerms method for publically exposing our database content. We are on IIS, so I was going to do it with WCF. However, other partners in the project also have to host an equivalent service and they are all Java based.
We are then building a software app that needs to connect to any number of these services (as defined at runtime by a user). I am expecting that we can have one set of classes to connect to these services (but with different endpoitn addresses), but am not sure whether I'm right in expecting this to work.
Is this possible?
And what considerations/restrictions are there?
Thanks.
It shouldn't be a problem, if you make sure that both services have equivalent wsdl files and you use http/soap binding.
I am not sure about using the binary (net.tcp) one with WCF, though. It might be a problem.
One way to do it is to use JAX-WS (Java 6) to expose a method as a web service.
The JAX-WS stack allows for automatically generating the correct WSDL at runtime.
The .NET team can then take that WSDL, and use standard tools to create a mock implementation of that WSDL. This mock implementation is then used as the actual .NET implementation, and you then use standard tools to generate the WSDL for that web service.
You now have to web services with the same semantics each with their own WSDL.
Both Java and .NET can implement a SOAP compliant web service, so the answer is yes, you can write a .NET and a Java webservice that implement the same WSDL.

how to consume a .net webservice from a C++ application?

I have a c++ application which checks the information about the printers in a given network. I need to store this information in database, using a webservice in another .net web application. But I m new to c++ and i have no idea how i can make a call to the webmethod in the webservice using c++. There is no add web reference option in the c++ application.
can anybody suggest me a good tutorial for this?
My application is a win32 console application.
Thanks,
Subrat
There is an MSDN article using Visual Studio 2005 named Walkthrough: Accessing an XML Web Service Using C++ and the CLR that should be similar to using Visual Studio 2008 C++.
You could use Axis from Apache to connect to web services.
Since you imply Windows, you might look at WinInet (look for it in msdn). WinInet is a very powerful and feature rich http client but also complicated to use, especially in asynchronous mode.
SOAP messages that are exchanged between client and server are basically XML documents and they are sent via HTTP (they are in the body of HTTP message). If you know the format of SOAP request and response you could use WinHttp API, or more general WinINet. Yet another solution is IXMLHTTPRequest. Be prepared to parse XMLs yourself, probably by using MSXML.
ATL Server is not available in VS2008 (it is released as community project so am not sure how keen Microsoft is to support this technology).
I used WinINet on WinCE to access Apache Axis2/C web service.
Look into gSoap - a great open-source, C/C++ library for accessing web services. I've used this extensively for accessing services written in .Net. Commercial and not-for-profit licenses available.
You just need the wsdl file/url and it will generate the client / server code for you. From the web site:
The gSOAP distribution package
includes two compiler tools to develop
your applications:
The 'wsdl2h' WSDL
parser. This tool converts WSDLs and
XSD files into annotated C/C++
definitions.
The 'soapcpp2' stub and
skeleton compiler. This tool generates
RPC code and XML serializers from the
annotated C/C++ definitions.
The 'wsdl2h' parser converts WSDL into
gSOAP header file specifications of
Web services. This specification gives
a C/C++ transparent view of the
server's functionality. The header
file is processed by 'soapcpp2' to
generate the source code stubs and
skeletons to invoke the service or
build a new service based on the WSDL.

How to implement a SOAP client in C# (specifically for Windows Mobile)?

I'm really confused about how to create a SOAP client in C# using .NET. I have found this page which looks really promising, but for the life of me I can't find Microsoft.Web.Services2. Also most information I find about SOAP with C#/.NET are about creating web services in ASP.NET and that's not what I want to do.
Basically what I want to do is implement a SOAP client in C# in a Windows Mobile application.
Download the old OpenNETCF.Web.Services2 source code (in the deprecated source downloads at the bottom of the page). Depending on your exact needs, this will probably provide the WSE classes you need.

Categories

Resources