Generating C# client code from a JAXB WSDL with a binding file - c#

I have a WSDL with dozens of XSD and I need to generate client code from the WSDL to consume a Web Service. The owner of the web service uses Java and generated the WSDL/XSD using JAXB. JAXB specifies a "binding file" for customized bindings, and the owner has generated a XJB file (JAXB customized binding file) to be used with the WSDL.
I need to generate my client code in C#, but svcutil and Visual Studio's Add Service Reference don't have any provisions for this customized bindings file. There are tools to generate Java client code that take a binding file as an argument, but no tools for C# generation. I've trying just running svcutil without specifying the XJB, but I can't get it to work. I've done extensive Google searches with no luck. Any ideas on how to make this work?

You can customize WSDLs by providing binding declarations, but these are Java specific and the customizations apply only while generating Java code from the WSDL. The bindings can be declared inline (embedded in the XSD/WSDL) or within a separate file.
You have a separate file so I'm thinking the WSDL and XSDs are "clean".
The JXB file is a red herring though. A WSDL is supposed to be technology agnostic, it doesn't care about Java, C# or whatever. You should be able to generate the code because svcutil will just ignore the Java bindings.
What error does svcutil throw at you? I've seen it fail with hard to understand messages when the WSDL was missing a <type> section. You mentioned dozens of XSD files, how are they imported in the WSDL and does the import work? If you open the WSDL in Visual Studio does it show validation errors, is it complaining about something?
Finally, if everything fails, you could feed it all (including the JXB file) to a Java tool like wsimport and get some Java files out of it. You can do a quick deploy with Endpoint.publish and then point svcutil to the deployed address plus ?wsdl and see if you get a different result.

Try out WSCF.blue and see if that is any useful in your case. Please note I am not familiar with JABX, but I am using this tool currerntly to generate code in C# from the wsdl.

Related

Problem exporting/importing and modifying a certificate template in C# using Certificate Template API

I am working on the import and export of certificate templates using Certificate Template API (see this link (https://techcommunity.microsoft.com/t5/core-infrastructure-and-security/introducing-certificate-template-api/ba-p/1128560). The code I am using is pretty much the same as in the link.
For many methods I get a Non Implemented error while others work. More specifically the export method gives me that error while the import is fine(I exported my manually created template using Powershell to an xml file to have something to import!). I would like to be able to use the export method as well. And all the rest!
Moreover, in the export method if I try to edit more properties, again, I get a non implemented error. See below:
IX509CertificateTemplateWritable writableTempl = new CX509CertificateTemplateADWritable(); //OK
writableTempl.Initialize(template); //OK
writableTempl.set_Property(EnrollmentTemplateProperty.TemplatePropSecurityDescriptor, SDDL); //OK
writableTempl.set_Property(EnrollmentTemplateProperty.TemplatePropFriendlyName, "Hello"); //NOT OK!
writableTempl .Commit(CommitTemplateFlags.CommitFlagSaveTemplateGenerateOID, null);
I am truly at a loss.
More info: I am running on windows Server 2016. I added to my C# project (Visual Studio 2022) as reference "Interop.CERTENROLLLib" downloaded from here: https://www.nuget.org/packages/Interop.CERTENROLLLib
I have tried to see if maybe I was using a wrong version of Interop.CERTENROLLLib. Since I could not do the Export with the API, I exported the certificate in Powershell using Vadims Podans method (https://www.sysadmins.lv/blog-en/export-and-import-certificate-templates-with-powershell.aspx) then embedded as a resource the resulting xml file in my c# application and used the Import API.
I really don't know what I could try to make the Export, and all the other "not implemented" methods work.
All I could find searching was the following discussion, my same problem but no solution offered. https://social.msdn.microsoft.com/forums/en-US/b507ccb8-1f72-4477-83e7-d0b221b3662c/enrolling-certificate-from-certificate-enrollment-web-services-using-c?forum=wcf

Updating a WCF .map file service reference

Working on a system and need to update a WCF service. The issue I am having is that the service file is a .map file. Using Visual Studio I would have assumed that I could just right click it from solution explorer and update the service from there, but there is no such option.
The .map file itself is an xml containing the Service endpoints and what not. It is also grouped with (could be a plugin "VScommands" that did this grouping) a .cs file of the same name containing the auto-generated code to use the service.
I'm unsure what other information I should provide but if someone could point me in the right direction it would be much appreciated.
So to get around this issue I had to manually enter in the inforamtion I needed. Did this by using the svcutil.exe tool provided by microsoft.
Real late update, decided to just remove the entire service reference and re-add it.

Using SVCUTIL.EXE to generate DataContracts for NOAA Forcast

I'm writing an API for NOAA forecast data, and I'm trying to get the information from a XML document like this into a de-serialized object. I Downloaded the schema and it's two dependacies (meta_data.xsd & ndfd_data.xsd ) and tried running this command
svcutil C:\DWML.xsd /dconly
But it returns with
Error: Cannot read D:\DWML.xsd.
Cannot load file D:\DWML.xsd as an Assembly. Check the FusionLogs for more information.
Can someone please walk me through the steps to create data contract for this xml document?
If there is an easier way to get this information into a easily querable form that doesn't require Data Contracts I'm willing to change my approach.
You need to supply all the xsd files to SvcUtil like so
svcutil *.xsd /dconly
However trying this with NOAA schema gives bunch of errors and it suggested to use /importXmlTypes. But the following did not work for me either:
svcutil *.xsd /dconly /ser:XmlSerializer /importXmlTypes
Finally, used Xsd2Code
xsd2Code.exe DWML.xsd
and it worked like a charm.

SOAP Web Service / VS2010 Add Service Reference

I am having problems gaining access to a clients web service online.
If I have the wsdl file, can I do "something" in VS2010 with it so I can add it as a reference and start my C# coding?
Thanks Paul
When you go to "Add Service Reference", the textbox that allows you to enter a URL, can also take a path on your local filesystem to a wsdl.
Additionally, while not the optimal route, you can also use the wsdl.exe/svcutil.exe utility (bundled with VS) to generate a proxy class. Adding a reference is the better way to go, but this is an additional option.
Adding the Service Reference as a local path worked for me like a charm. I would have voted +1 for xelco52, but my rep is too low...
Only 1 issue; one of my members of the class I've added does not work. I wonder if I need to use the sledgehammer...?
If you have the WSDL file, under one of your projects in VS, right-click the References project folder and choose Add Service Reference. Click the Advanced button, and in the new dialog click Add Web Reference. Now, go find the WSDL file, either where you saved it or where you downloaded it, enter its location in the textbox, and click Go. VS will digest the WSDL and produce a class that is the service client, and others as necessary to implement custom types accepted by the service.
It's usually a good idea, if you have downloaded the WSDL, to include it as an item in the project that has the web reference; that allows it to be easily traversed as a reference source, and to be located should you need to recreate the web service classes.

Can intellisense be exported or extracted from Visual Studio to a text file?

I'm trying to write some documentation for a webservice that has been provided by one of our vendors for an application we're integrating. A bunch of the interface is custom objects defined in the web service itself. The vendor has put up significant resistance to providing any documentation for this application and so I've taken it upon myself to do their job for them [against my better judgement].
The documentation they have provided frankly is embarassing and I'm trying to make as short work of this as I possibly can to put some good quality docs together. I know that as I don't have access to their source, I can't just run it through nDoc/Sandcastle to spit out an API doc, but I was wondering if (as a half way house) there was an easy way to export the intellisense to a text file without me having to write a utility to specificially iterate through each of the object types defined and reflect the members out to text?
If I could do this, it would at least make sure that I have a good quality document structure where I can just fill in the blanks. Having to skip back and forth to Visual Studio to check the intellisense for every class member is a very laborious way of doing this.
Does anyone have any ideas?
If it is a web service that you are trying to document, couldnt you then parse out the WSDL?
If you are accessing a remote Web Service, then I think you have access to the corresponding WSDL: what about parsing it and look for just the information you need?
Or using a tool to do this (I Googled for "wsdl documentation generator")?
Or even using WSDL.exe to generate some dummy code from the WSDL and then document it, perhaps helped by GhostDoc?
HTH
Could you use Reflection to dump out the methods etc.?
Reflection is the feature in .Net, which enables us to get some information about object in runtime. That information contains data of the class. Also it can get the names of the methods that are inside the class and constructors of that object.
I think VS.net generates documentation for intellisense. For existing assemblies, it is already on your file system (e.g. C:\Windows\Microsoft.NET\Framework\v2.0.50727\en)
Try using the assembly from the vendor in VS.NET. Use process explorer or any such tool from sysinternals to see what files are being loaded. I am sure, you will find that there is an xml file created for the custom assembly (which is used to show the Intellisense and documentation available with it).
Hope that helps.
EDIT: I think the same folder (where your custom assemblies are located) will have the xml files for documentation.
If you have the dll's could you not decompile them and then recompile and use nDoc? That should give you a reasonalbe start.
Could you just use reflector (from redgate) to view the assembly (decompiled) instead of reproducing a API document. I'm not sure what else you would get of reflecting and building your on document that you wouldn't see live in reflector (of course this would depend on their writing readable code.
Maybe this is crazy, but could you take a screenshot of the full listing, and run it through an OCR program?

Categories

Resources