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.
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 want to make a call to a web service that is written in C#, through Visual C++ or C++ in Visual Studio 2010. I searched on web but was not able to find any point to point document. It would be a great help if you will tell me.
If you're prepared to go with managed C++ then you can use WCF.
However, if this isn't an option then your best bet is to go with a socket approach. You'll need some cross-language way to represent the data your sending from C++ to C# and back again. Google Protobuf will help here as there are frameworks for both languages, in addition to many others.
A web service uses something JSON or XML as an interface and is inherently language independent. You would have to look for libraries that can create requests to the web service. For example if your web service in C# uses SOAP (XML) which it would if you created the default web service in Visual Studio you could create your own request in XML in accordance to the specifications of SOAP:
http://www.w3.org/TR/2000/NOTE-SOAP-20000508/
or use one of the libraries mentioned in this question:
Generic WebService (SOAP) client library for C++
Have a look at Walkthrough: Accessing an XML Web Service Using C++.
I would like to create a c# dll that handles requests. I would like the requests to come as webservice calls so that websites can quickly call the dll. Is there a way to integrate the two - to have the code for the webservice be placed inside of the dll?
Or, if the webservice has to be separate - is there a way with visual studio to put the webservice into the project with the dll but tell the compiler to compile it as an external file? That way this would at least help me keep my project structure simple and clean.
It's unclear to me what you're really trying to do. "A DLL that services requests" can be implemented in any number of ways.
One way to implement a Web service in a DLL would be to use an HttpListener.
You'll have to supply more information about what exactly you're trying to do before we can provide reasonable answers.
All you need to do is create a new WCF Service Project. This will cause your services to be created as a separate application under IIS. Both projects would be in the same solution.
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.
I have a WCF service that I have to reference from a .net 2.0 project.
I have tried to reference it using the "add web reference" method but it messes up the params.
For example, I have a method in the service that expects a char[] to be passed in, but when I add the web reference, the method expects an int[].
So then I tried to setup svcutil and it worked... kind of.
I could only get the service class to compile by adding a bunch of .net 3.0 references to my .net 2.0 project. This didn't sit well with the architect so I've had to can it (and probably for the best too).
So I was wondering if anyone has any pointers or resources on how I can setup a .net 2.0 project to reference a WCF service.
One of those instances that you need to edit the WSDL. For a start a useful tool
http://codeplex.com/storm
What binding are you using - I think if you stick to the basicHttp binding you should be able to generate a proxy using the "add web reference" approach from a .net 2 project?
Perhaps if you post the contract/interface definition it might help?
Cheers
Richard
Thanks for the resource. It certainly helped me test out the webservice, but it didn't much help with using the WCF service in my .net 2.0 application.
What I eventually ended up doing was going back to the architects and explaining that the 3.0 dll's that I needed to reference got compiled back to run on the 2.0 CLR. We don't necessarily like the solution, but we're going to go with it for now as there doesn't seem to be too many viable alternatives
I was using the basicHttp binding but the problem was actually with the XMLSerializer. It doesn't properly recognize the wsdl generated by WCF (even with basicHttp bindings) for anything other than basic value types.
We got around this by added the reference to the 3.0 dll's and using the datacontract serializer.