How to create a service based in a WSDL of another service - c#

I am really new in services and are having some problems with one issue. The fact is, i have a WSDL of a SAP system and i need to create a Web API in Visual Studio based on it.
I passed some time searching for tutorial's of how to do that but don't have lucky. Someone would help me, explaining the concept or sending some tutorial where i could understand how to do that? I am completely lost and i need it for my job.
If anyone could help me i would stay quite grateful. Thank you everyone for the support.

Just host the WSDL in ur IIS i.e Create an application in IIS pointing to the directly that contains the WSDL.
And add service reference to the WSDL by pointing to the IIS Url of the application.
Then in config, change it to point to actual implementation of the service.

If you have WSDL of the service you might be able to use ServiceModel Metadata Utility Tool (Svcutil.exe) to generate your WCF client proxy with all the required contracts for it. Here is another link on generation and answer with an example, plus another example.

Related

Basic WCF - how will the consumption of a WCF service translate to a 'real-life' deployment?

I have created a WCF service.
I am now following tutorials on how to consume this service, and the way I've been instructed to do this is to...
"..note the http address and port that Visual Studio is using to run you WCF webservice. It may look like this ([LOCAL HOST ADDRESS]). You will need this url from within the Windows Form to add a reference to the WCF service.."
http://www.thebestcsharpprogrammerintheworld.com/blogs/create-and-consume-a-wcf-windows-communication-foundation-service.aspx
Now, that's fine. But if I'm literally going to copy and paste this url into my application it will no longer be relevant to a live environment will it?
Is this really the best way to point to a WCF service in a solution?
You will see that in your app.config file the url is saved. If you deploy your service to a live server you will only need to change the config to look at the new url.
Hope I understood your question.

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.

wcf and inserting information into the web.config

Why does WCF not insert basic information about my service into the web.config? Is there a way to make it to that?
I'm talking about when you add a wcf service to project explorer
You can always use SvcConfigEditor to configure your services or clients. This has a nicer (but far from perfect) UI which can help you going quickly.

Using the same class in both server and web service

I have classes that are needed in both my web service and my server.
For example, I have a class named Order that I'd like to send from my server to the web service and vice-versa.
Problem is that the class in the server is Order and the one on the web service is localhost.Order, and it is impossible to convert between them, even though they are built from the very same code. Error is cannot convert from 'Order[]' to 'localhost.Order[]'.
What can I do? Thank you very much.
when you add reference to web service you can specify which classes to reuse. by default it generates classes based on WDSL that web service produce.
The namespace used is determined by the name you give the reference when you add it.
For more information see this answer to a similar question:
Unable to cast object of type MyObject to type MyObject
You should maybe have a look at WCF services:
http://msdn.microsoft.com/en-us/library/bb332338.aspx
I've used these on a few projects where both have references to a shared library, and one web site will request one of these objects via a WCF service call from another site. It's very clean, and it opens up other options for transport/security which can be very useful.
The question appears to suggest that you are using ASMX Web Services. If so, you have your work cut out for you.
Jelle Druyts wrote an extension for ASMX that can do, more or less, what you're asking. You have to configure your shared types at the machine level (machine.config). It's not pretty.
There's also a fix for that extension to make it work with nullable types.
Good luck getting this to work with Visual Studio 2008 or on Vista/Windows 7. You'll be OK if you're still running XP with VS 2005.
If you can, you really should consider using WCF for the client proxy instead, since WCF makes it very easy to share types. In fact, the Visual Studio 2008 integration does this by default; you just need to make sure your client project references the assembly containing the service types.

Developing .NET Web Service from WSDL file

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.

Categories

Resources