I have been provided to a wsdl file by another business to build webservice so that the other business can connect to service I build using the provided wsdl and xsd files. I am dot net developer using wcf. I want to know where to start having the wsdl and xsd files in hand.
Thanks
Hopefully, the schemas and WSDL are .NET friendly. If you want to use WCF, you can generate your classes using SvcUtil.exe.
svcutil -noconfig -serializer:datacontractserializer -d:../
-namespace:*,MyCompany.Services.ServiceName wsdl.wsdl Messages.xsd Data.xsd
The bad news is that svcutil actually generates the client side proxy so you have to manually go and remove the client and channel classes.
For a full description of this approach see Schema-based Development with Windows Communication Foundation.
In the article, they also talk about a Visual Studio add-in, WSCF.blue, that allows you to do Data contract generation (among other contract first development tasks).
You can use the .net wsdl tool and xsd tool to auto generate your classes.
The quick and lazy way of doing it is simply to use add reference in VS (assuming .net3.5 +) or add web reference for .net 2; and allow VS to do the work.
http://www.eggheadcafe.com/tutorials/aspnet/a1647f10-9aa4-4b0c-bbd9-dfa51a9fab8e/adding-wcf-service-refere.aspx
As ( http://andrewtokeley.net/archive/2008/07/10/the-difference-between-ldquoadd-web-referencerdquo-and-ldquoadd-service-referencerdquo.aspx ) says its basically a wrapper for the functions the Tuzo and Ben added.
Makes life easier though and with the 'Add service wrapper' you can use the advanced settings to automatically generate ASync classes & Data Contracts.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I want generate C# classes from wsdl url in ASP.NET Core 2.1.
WSDL url is:https://airarabia.isaaviations.com/webservices/services/AAResWebServices?wsdl
I used "Microsoft WCF Web Service Reference Provider" tool to generate C# class and got following error:
Error: No code was generated.
If you were trying to generate a client, this could be because the metadata documents did not contain any valid contracts or services
or because all contracts/services were discovered to exist in /reference assemblies. Verify that you passed all the metadata documents to the tool.
Done.
Any solution will be appreciate.
Short answer
Open a development command prompt and run to generate the proxy classes:
svcutil http://airarabia.isaaviations.com/webservices/services/AAResWebServices?wsdl
Notice that I used http instead of https. The server's certificate causes problems with svcutil. Copy the classes into your project folder.
Add System.ServiceModel.Primitives from NuGet to the project's dependencies. Since ASP.NET Core doesn't use web.config files, you may have to create the bindings yourself when creating the proxy class, eg :
var binding = new BasicHttpsBinding(BasicHttpsSecurityMode.Transport);
var address = new EndpointAddress("http://airarabia.isaaviations.com/webservices/services/AAResWebServices");
var client = new AAResWebServicesClient((Binding)binding, address);
In the bindings, BasicHttpsBinding is used since no airline will accept unencrypted connections. Sabre requires TLS 1.2 or greater.
Explanation
Airlines and GDSs aren't great at following web interoperability standards. They are big enough that if there are any changes, it's the travel agent that has to accomodate them. Once they specify their standard, they don't care to change it either.
The OTA standard and Sabre's implementation for example were created in 2003 using ebXML, an alternative proposal to SOAP that didn't become a standard. Then they used ebXML over SOAP using mechanisms that didn't become part of the later SOAP standards. When the WS-* standards were created to fix the mess and ensure interoperability, they didn't even bother.
The WSDL you provided is similar to Sabre's. It uses some of OTA's operations like OTA_PING and adds custom ones. Fortunately, it doesn't include any tool-breakers like anonymous inner types.
You could use wsdl.exe to create an ASMX proxy, using the pre-2008 .NET stack. This hasn't been ported to .NET Core as far as I know though. Maybe it's part of the Windows Compatibility pack. After all, it is non-compliant and deprecated 10 years ago. ASMX hasn't had any significant upgrades in ages either. I have run into concurrency issues with deserializers in the past, when using ASXM services eg with Amadeus.
And then, there are those that won't even respect their own XSDs, eg Farelogix. They may return out-of-range values for enumerations and say "well, the XSD is for information purposes only". The wsdl file is clearly marked not for production use
There's no generic solution unfortunately. Here are some options:
wsdl.exe and ASMX are out of the question if you want to use .NET Core. You'll have to switch to the Full framework if you have to use them.
Create WCF individual proxies for each service. The size of the files is a lot smaller and you avoid clashes between types like Airport that are used by multiple services with slight variations or even incompatibilities.
Use Fiddler or another tool to capture the requests and responses. Use these as templates to create plain HTTP GET requests. It's a dirty solution but could prove quicker and ever more reliable if you can't trust the provider's WSDL and XSDs
WARNING
Making the call doesn't mean that you can communicate with the provider. One of the main problems with ebXML over SOAP is that the body is OK but the headers, including those used for authentication are all wrong. This means that one has to create the authentication element
Another issue is that authentication fields are often misused eg using authentication headers we'd consider session tokens. GDSs still use mainframes and those session tokens often map to actual terminal sessions.
This means that one has to create authentication headers manually instead of relying on WCF to generate them. It also means that transactions are stateful - one has to keep track of which session was used for that reservation in order to book it, make sure all previous transactions are complete before starting a new one etc.
Download your WSDL files to local. Then, run the following command:
wsdl.exe /verbose /namespace:Air /out:D:\t\ar /protocol:SOAP /language:CS C:\path\to\wsdl\AAResWebServices_1.wsdl
Change namespace to a namespace of your choice.
WSDL.exe is part of your Windows SDK:
C:\Program Files (x86)\Microsoft SDKs\Windows
Mine was in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin
This generated the classes without any issues. I tested this solution.
I often have to create a soap web service which needs to conform to certain documentation. In particular it is often some OTA flavour. (open travel alliance)
For example the service needs to receive OTA_HotelRateAmountNotifRQ and respond with a OTA_HotelRateAmountNotifRS. Generally the syntax of those messages can be downloaded as .xsd:
http://www.opentravel.org/2004A/OTA_HotelRateAmountNotifRQ.xsd
What I would like to do is simplify the process of creating such a service (right now I'm using XDocument and analyze/create the XML by hand).
So assuming I have access to particular XSD files, how can I automatically create corresponding code/classes, wrap them up in SOAP and use as a basis for a web service?
I hope the question makes some sense, any help would be appreciated.
You want to use the XSD to model your WSDL. Then import your WSDL into Visual Studio. This is called the top down or WSDL first approach.
If you dont have a decent WSDL editor such as Altova XML Spy or Liquid XML I would suggest you invest in one as it will make this rather easy.
See Walkthrough: Designing Application Systems by Using a Top-Down Approach for an example.
I wonder if there any way to extract the methods and the related input parameters from a WSDL web service in c#. Specifically i need a way to provide the endpoint URL of a web-service and get as a result the above information. Something like the "Add Service Reference" in VS. But what i want is to get those information by implementing a module and not by using any other tool. Does .NET provide any functions for that? I'm using .NET 4.5.
Thank you
You have 2 good options that come with .NET and you need to access both from VS command prompt.
wsdl.exe -> this does exactly what you are looking for.
wcftestclient.exe -> this helps you test any webservice even before you add it to your project.
EDIT 1: I think I misread your question. Well you can always use the generated class file by WSDL.exe in your application.
I am attempting to create a few WCF web services from existing WSDLs. There are a few awesome questions on SO for this, (1, 2, definitely more) but many of these are from 3 years ago, and I end up wondering if the advice is still valid. If it is, how do I finish integrating it into a WCF project in Visual Studio 2010? The questions and linked blog posts are considerably mum about how one configures a .svc to use the converted WSDL after it's been run through svchost.exe (see linked question 1 for details on that), and a blog post linked in the thread suggests there is a way to make Visual Studio create a .svc around a converted WSDL, but I cannot find this anywhere in either the program's interface or the documentation.
So, the question, I suppose, would be: What is the generally recommended way to approach contract-first web service design in Visual Studio 2010/.NET 4.0?
It hasn't changed. You can still generate a service interface and its data contracts using svcutil and a WSDL. Even a client will be generated, though you won't need that.
You can then create a .svc-file, which merely instructs a ServiceHost which class to host, as explained here:
<% #ServiceHost Service="MyNamespace.MyServiceImplementationTypeName" %>
Your implementation of course has to implement the generated service interface.
As an ASP.NET developer, I'm used to working with how VS/C# transparently autogens proxy classes for web references via wsdl.exe (yes, I know, we're spoiled), but now that I'm creating documentation for more than one coding platform I'm trying to discover what the equivelant to that is in any other framework.
So is there a similar way to work transparently with web reference proxy classes for say, RoR, PHP, and Python?
And if there's nothing integrated, are there tools you recommend to autogen the proxy classes, or do you recommend to roll custom classes?
I've had (limited) success with ZSI http://pywebsvcs.sourceforge.net/ for Python. Try at your own risk.
If it would be possible to run IronPython or IronRuby I would check that out.
I definitely know how VS can spoil you.