Differences between imported service reference and generated wsdl - c#

I imported a service reference using wsdl, this wsdl contains classes and methods, some of which to be implemented in my web service. Now, publishing my WS and trying to get the wsdl I notice a lot of differences between the imported one and the generated (namespaces, "ArrayOf" prefix in collections, ...).
I'm using just the classes provided by the original wsdl, so I can't understand why the wsdl of my WS has to be different...
I need to output a wsdl identical to the one imported because they will be both imported from my customer to make an interface, so everything has to be coincident.
Thank you

Without knowing more details, I don't see why your customer is being handed two WSDLs.
To simplify things just hand the generated WSDL from your web service to your customer. If there are things in the imported WSDL that are not in the generated WSDL I would just duplicate the missing pieces in your generated WSDL.
The generated WSDL probably contains more generic definitions of collections than what you provided so that it is compatible with different client languages.

Related

How to create a WCF service from c# classes generated from an xsd

I have a complex xds file I need to create a WCF SOAP service based on. I have generated the classes using xsd.exe. The resulting classes uses XML serialization.
My challenge is how to use this class to build a service. Please any suggesting a recourse that can guide me will be highly appreciated.
Basically the c# classes generated when I run xsd.exe xsdfile.xsd /classes is all that is needed. I just created a new wcf service and in the operation contract passed the generated c# object as the parameter and that was it. It worked

.NET tool to generate wrapper for proxy classes

Using SvcUtil I generated proxy for a SOAP WebService. This webservice has many complex types and can change every year. Is there a tool I can use to generate wrapper for all classes. Using composition in wrapper class I will call proxy class.
Svcutil.exe generate POCO types at the client sides according to the XSD parts of WSDL. There shouldn't be T4Template involved which is too complex and overkill and inappropriate. Svcutil.exe could have created all the proxy classes you need.
If the complex types may be changing every years, you may consider versioning.
Once an interface is published, you should not changed it. This applies to both operation contracts and data contracts.
You may refer to this article WCF for the Real World, and google WCF versioning.
So basically you explicitly declare XML target namespace in the contracts, and map CLR namespaces with XML namespaces. When you need to change the complex types, you have to provide another version of WCF service. During the transition period before all the clients could upgrade to the latest version, you keep both versions running.

JavaToWs share types

I have a server in Java which has some web-services. WSDLs (and XSDs) are generated from java using javatows from apache cxf.
Some services share types, and I would like to share these types also in wsdl is it possible?
After that I want to generate c# code using svcutils, but because in each WSDL are some copies of the same types svcutil tell error that this complex type has already been declared...
I know that I can use /namespace switch but I do not want this because that way I will have the same classes generated in different namespaces... I would like to have one class in common namespace...
I suggest you create a common.xsd file (if possible) containing the shared structures which are then included in each WSDL file for each one of the services.
<include schemaLocation="common.xsd"/>
I believe that will overcome the problems you're having when generating client proxy code with svcutil.exe.

How to create wsdl from xsd

I want to create a wsdl by using 3 xsd-files. How do you that?
I tried this in the command prompt:
wsdl.exe /language:cs /parameters: c:\myService\Contract\HeaderData.xsd c:\myService\Contract\MyData.xsd c:\myService\Contract\Messages.xsd /out: MyWsdl.wsdl
What do I wrong?
I believe that there's a misunderstanding here. Most likely the wsdl.exe in your illustration refers to Microsoft's tool, which is described as:
The Web Services Description Language tool generates code for XML Web services and XML Web service clients from WSDL contract files, XSD schemas, and .discomap discovery documents.
From what you seem to imply by asking the output to be a WSDL file, I can safely assume that you really try to create a WSDL file starting from XSD files. Below I am trying to explain why you cannot do that that easy, and what options you have.
The diagram below shows you the model behind the WSDL 1.1 specification.
Your XSDs fit exactly, and only under types. It WSDL terms, types represent your type system used to describe the parts that make up messages, which are then used to describe input/output and faults of operations organized as ports (abstract interfaces) bound to application/transport protocols, and ultimately made (physically) accessible as services at one or more network endpoints.
To generate WSDL(s) out of XSD(s), you realized by now that you need to provide some more data to a tool that would automatically generate a WSDL for you. For example, what operations you want to describe in your WSDL? For each one of them, what's the input, most likely the output and maybe one or more faults? How would you group them (portType = interface)? What binding do you want to use: HTTP, SOAP? What version of SOAP? SOAP over: HTTP, MQ? SOAPAction? How many WSDL files: 1, or maybe 3?
Some tools may ask you a series of questions (data entry/wizards) along the above lines and then create the WSDL(s) for you. Others, use predefined patterns in the implementation of XSD schema constructs (for example, IFX has a certain way to define Request/Response elements) so based on those assumptions a specialized tool such as QTAssistant (I am associated with it) would ask you less questions, while still creating the WSDLs.
I remember one or two online tools that were able to allow the user to upload XSD files and then create WSDL after prompting you a couple of questions, but I can't seem to find them anymore... kind of like this one...
From my understanding, you don't go xsd->wsdl, but I could be wrong.
Generating a WSDL from an XSD file might help clear it up for you though.
You cannot auto-generate a WSDL from an XSD in this manner. In order to create the WSDL, you need to start with a new WSDL and import this XSD.
The XSD defines the types of data that are available for services. Some XSD is usually embedded in a WSDL, some are imported specifically.
An alternate way is to use the XSD in C# to generate a service, and then extract the concrete WSDL from that service, but this is not preferred as many teams prefer contract first web services.

how to generate wsdl with SvcUtil?

Is it possible to generate wsdl with use of SvcUtil or any other tool. I know I can view wsdl in browser while running the service but I need to have one wsdl file that doesn't have xsd:import directive but rather specifies all the information in this file.
If it's a one off you could manually construct the single WSDL file. But that's no fun. :)
Another way is to create an endpoint behavior. See Improving WCF Interoperability: Flattening your WSDL for the full details.

Categories

Resources