Developing .NET Web Service from WSDL file - c#

What's the best practices for developing a web service with a WSDL as a start point?

Use SvcUtil to generate your service interface and then develop a service against that. Here is an example.

Your question is a little vaque, but developing web services with .net is quite easy.
Using visual studio, most of the things are generated for you. You can add methods as
[WebMethod]
public string hello(){
return "hello"
}
and luckily once you deploy it, the wsdl is generated for you.
If you are looking to download some entities from a wsdl, you can use the wsdl utility and invoke a wsdl to download the entity class.

Check out the WCF Developer Center on MSDN - it has tons of tutorials, article, screencasts that show you how to create a SOAP based web service, based on code or WSDL.

I found this question helpful when I had the same question in the past.
Create an ASMX web service from a WSDL file
The problem I had was that I was given a WSDL. I needed to create web service methods based on the contract that the WSDL provided.

Related

Web service in C#

Previously I used web services sample from console application, but I don't have much knowledge in that in terms of understanding in xsd and wsdl.
I would like to consume the complex web service to understand xsd and wsdl.
When goggling found some sample free web services, they have provided wsdl file, and service url. I am able to add the web reference in C#, but not understanding how and which method to call, could any body can provide sample code to consume?
Service URL: http://www.webservicex.com/globalweather.asmx?WSDL
Web method : GetWeatherResponse
When I add the service reference from the application I am able to see the these classes.
input1, input2, input3, input4,
output1, output2, output3, output4,
ArticleType, ArticlePtServiceClient, ArticlePTservicechannel
but I'm not able to view GetWeatherResponse()
From the wsdl file can i get to know from which class object we can call the web method?
Theoretical understanding is we can find the web method based on the wsdl.
Eagerly awaiting positive responses. Expecting sample code to call this web method from the web service.As well as requesting you to some references to better understand complex type xsd's.
Thanks in advance.
After lot of R&D understand littele things regarding Web service and WCF.
The only solution is We have to create stub to test in local environment.
Createing stub :
SVCUTIL
still need to learn more, more questions are there in mind. will update here for our reference.

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.

Microsoft Client - Java Web Service

I have to consume a Java web service and want to do it using Microsoft Visual Web Developer in C#. I will be adding the endpoint of the web service as the web reference and hopefully go from there, however I am concerened if there will be any interoperability issues? Any help would be appreciated.
There won't be any interoperability issues if the Java web service respects the standards.
You should be able to generate a client from the WSDL and XSD that describe the service. This ought to be fairly routine.

How much effort is required to convert an ASMX to WCF web service?

I have 2 web services with about 6 web methods in total, most of the code is ofc sitting in assemblies any way, and the web service asmx is really just calling these assembly methods and returning their return type.
How much effort is it to convert the web services from ASMX to WCF?
I pretty much at this stage control the only - non web based clients connecting to the web services, so this is not really a problem, product is in prelaunch.
Check out some of those blog posts and articles on how to do it:
Migrating ASMX to WCF (unfortunately, this link in no longer valid)
Phased Migration From ASMX to WCF
ASMX to WCF migration
and many more - search for "Migration ASMX to WCF" and you'll get a ton of hits
Marc
You should find it extremely simple to convert - especially if your existing asmx web methods are just calling into other classes. Just create a new WCF Service from Visual Studio - that way you still have your existing web services intact. It will automatically create an http end-point for your so you can just dump it straight into IIS (with a little configuration). You will need to describe your DataContract classes but that it trivially simple too.
I did this recently and it was a joy!

Categories

Resources