WSDL Importer not generating list correctly - wcf

I have this service: https://mnavwcfservices.stcenergy.com/FlexProcurementService.svc?singleWsdl
I am trying to use this inside Delphi XE5
I have used the WSDL Importer
The generated file is here https://www.stcenergy-online.com/dev/service.txt
Although the top level classes have been generated correctly, the lists are using list of AnyType
How do I get the correct classes to be generated?
One example is ClipMonthSummaryLine - this is in the wsdl file but does not make it into the generated file by the WSDL importer which I think is why the ArrayOfType has come in

This appears to have been caused by the use of interfaces in the C# classes
This is an absolute nightmare for me now as I never have lists of concrete classes but I think I can get round this by creating new classes that use concrete lists and mapping the data
Sir Rufo's response suggested using the Web Services Toolkit as opposed to the default WDSL importer that comes with Delphi. Although this looks very good it has proved to be a total nightmare to use to the point I may have to raise a new question about it. My new problem https://stackoverflow.com/questions/25961758/list-not-loaded-correctly-from-soap-message-wcf may have been caused by the default importer as well, but getting the files generated by the toolkit to work in Delphi is a nightmare and the documentation is not as good as it first appears.

Related

Portable Class Library doesn't know ArrayList, StackTrace, etc

I'm hoping I just missed something in the README somewhere, but...
I have a library of VB.net code that I'm trying to package into a PCL, ultimately for use under Xamarin. The code is relatively straightforward, there's a lot of File I/O using streams and some SQL client code, and a smaller amount of UI and control related code.
So I made a new PCL project, but I was confused what to select, so I chose Windows Store and .Net 4.5. I then Add...ed the source files from an existing project. Now I'm getting errors on the most basic things - ArrayList does not appear to exist in spite of importing System.Collections, and StackTrace doesn't exist in Diagnostics. Even simple things like StringFormat and SortedDictionary aren't there.
Did I skip a step somewhere? Perhaps I didn't download the right libs from MS? Or maybe I have to manually include a Reference to something? Any ideas?

Taking control of WSDL/XSD from WCF-SVCUtil (Annotations, Schema Namespaces, and Schema Locations)

In the WSDL that is generated from a WCF service, there are a few problems that I'd like to take control of a little more. First, is there a way to add annotations to the xsd files generated with the WSDL without using surrogates?
I've taken care of adding annotations to the WSDL itself thanks to the following articles:
http://msdn.microsoft.com/en-us/library/system.servicemodel.description.iwsdlexportextension.aspx"
http://www.codeproject.com/Articles/29980/Exporting-Annotations-from-WCF
I was able to add annotations to data members through agillior, however they used surrogates which I would rather not use.
http://agilior.pt/blogs/bruno.camara/archive/2006/10/01/6.aspx
I would use Thoranin's solution except I want to apply the annotations to data members not parameters
http://thorarin.net/blog/post/2010/08/08/Controlling-WSDL-minOccurs-with-WCF.aspx
Second, I want to explicitly name the namespaces for the xsd files generated from the WSDL. I was able to take control over the namespace of the wsdl using the ServiceBehaviorAttribute: [ServiceBehavior(Namespace="http://mysite.com/HelloWorld")]
but unfortunately I can't find an easy way to specify the namespace of the xsd files :(, is there a simple way to do this/can you point me in the right direction?
-edit-Well I was being silly on the second request. I had forgotten to set the namespaces for my wcf files which is what maps to the xsd namespaces. My bad :) .
Lastly, when the wsdl imports an xsd, it uses a path similar to http://localhost:8080/HostDevServer/HelloWorldService.svc?xsd=xsd0
which seems to break the wsdl2java ant script by apache. I can go in and manually change them to the local files but it's just such a pain :). Is there any way to have the files generated and then have a local reference like:
HelloWorldService.xsd,HelloWorldService1.xsd etc?
Any feedback would be appreciated.
WCFExtras ftw:
I decided that instead of having my own attributes and classes put documentation/annotation into the WSDL and XSD files I would just give into the hype and let WCFExtras take care of it. That being said I do wish that the Xml comments would be split into different lines instead of having them all on the same line. (Just to make reading the xml files easier). Plus WCFExtras takes care of the surrogate problem perfectly :) !
Ended up writing a program to solve the third issue. It pretty much grabs the metadata files using svcutil then goes in and finds all the imports, and reassigns them to the files downloaded based of off the namespaces.

Why do WCF clients depend on the app.config file?

Like a lot of things, I'm sure there's a good reason for this, so please help me understand...
Why, by default, do WCF services store settings in app.config?
This has been so frustrating trying to work with multiple Silverlight class libraries. These class libraries are supposed to be completely independent from each other, and this dependency on the app.config seems to cause the following headaches:
Single Responsibility Principle - I should be able to add a reference to a class library and go. If that class library uses a service reference, this idea is shot before I even start coding against it.
Muddy Configuration - To get other libraries to work, I have to copy and paste the service configurations into the "main" application configs. If an endpoint changes in any way, I can't just worry about a new version of that class DLL - I have to worry about anything that uses it, too.
Complex Alternatives - Programmatically creating the endpoint isn't pretty. Period.
There has to be a better way. Why doesn't WCF at least separate the service configurations into a ServiceName.config or something that gets copied to an output directory. What am I missing? How do you deal with this?
Because the alternatives aren't pretty either. The problem with "ServiceName.config" is that ServiceName also needs to be configurable.
The root problem is having Service references in libraries to start with. And a library component cannot dictate a binding for an App. So your SRP argument does not hold.
I concur with #Henk - library assemblies shouldn't have WCF references. If for some reason it does require one, i would use dependency injection, and pass the service reference in to the library function - this is vitally important for maximum testing benefit.
I also don't buy your argument of "Programmatically creating the endpoint isn't pretty". Creating and assigning an end point is just a couple of lines of code, and is a technique i use almost exclusively with my Silverlight components (e.g. if no address is specified within the ServiceReferences.ClientConfig file then i fall back to known service locations within the hosting application, in which case those endpoints are programmatically created).
Basically, if you don't mind the couple of lines of code required to programmatically create an end point, then you can store your address details anywhere, in any config file. You only need to store the addresses in the app.config if you are going for a purely declarative approach.

Creating bindable classes from WSDL for Flex 3

Two of our apps are web applications with a Flex 3 front end and a SOAP-style WCF back end. To communicate with the back end, I generate web service client classes through Flex Builder 3. Everything's functional, but maintaining those generated classes has been quite annoying, and I'm looking for a better way to do things (without having to do a major rewrite, of course). Here's the problems:
I use Flex libraries to manage components shared among applications. Some of them are dependent on the generated classes, so I need the WSDL-generated classes in their own library. Flex Builder 3, however, only generates the classes for a Flex application, so I have to generate the files in the application's source tree, then manually move the files every time. This also introduces strange side-effects with the way that Eclipse manages source code (why can't it just monitor the FS like other IDEs do?).
We use data binding in the MXML to declaratively tie data to the UI. I like data binding. Unfortunately, the classes in the WSDL-generated code do not support binding. Therefore, I opted to create a program to alter the ActionScript classes, adding [Bindable] metadata to them. This has to be run every time we regenerate the code.
Flex has a very nasty bug, known about at least since March, which still hasn't been fixed: http://bugs.adobe.com/jira/browse/SDK-19811. I recently discovered this, because it was double-encoding some XML characters like < and & into < and &. Therefore, I also had to add a workaround for that to the ActionScript manipulation program.
The WSDL-code generator in Flex Builder creates a String, Boolean, Int, and other classes which are built-in types! We're always having to delete these source files to prevent the Flex compiler from sometimes balking.
It seems unlikely to me that everyone is just putting up with these issues. There must be some alternative way of generating web service proxy classes for Flex that others are employing. Since I'm time-prohibited from making the communication layer RESTful and rewriting the front end in Silverlight, what do you suggest?
You can use one of several mechanisms to read the WSDL into a program and generate whatever flex code you need.
You can use one of the two ServiceDescription classes to read in a WSDL and examine its contents in terms of an object model;
You can use T4 Templates in Visual Studio with a bit of custom work to expose the WSDL to the template (possibly through the ServiceDescription class, as above)
You can use XSLT to transform the WSDL into the code you'd like
You can write some standalone program to read the WSDL (as XML or an object model) and just emit the text you want for your proxy code.
The bottom line is that, if you're having problems with the automation tools, then there are practical ways of creating your own.
Unfortunatly Flex 3 code generation from WSDL lacks from the Bindable tag, and it is a nightmare to handle that problem manually... especially if you have a complex scenario with lots of Types.
You could just add the tag manually and remove the "generated.webservices" from all variable declarations in order to make the code compile... and then you have another problem:
What if i have to generate de code again? Either i do everything again... or i will have a bunch of runtime only detected bugs...
I used ANT to a small trick:
Add Bindable to all classes;
Remove the full namespace from all variable declarations;
<target name="updateGeneratedCode" >
<replace dir="PATH TO YOUR GENERATED CODE">
<include name="**/*.as"/>
<replacetoken>public class</replacetoken>
<replacevalue><![CDATA[[Bindable]public class]]></replacevalue>
</replace>
<replace dir="PATH TO YOUR GENERATED CODE" value=":">
<include name="**/*.as"/>
<replacetoken>:generated.webservices.</replacetoken>
</replace>
</target>
Note: the replace token ":generated.webservices." may be different in your case, so you may want to replace it by your generated namespace.
It is working for me so far.
Hope it helps someone!
Antonio Inacio

Object Oriented Update Approach

I've been tasked with maintaining an application originally written in VB6. It has since been imported into VB .Net and to say the least the code is anything but Object Oriented. The code is riddled with classes which contain nothing more than Public Shared attributes(variables) and methods(functions), the result of which restricts the application from opening more than one project at a time.
A project consists of a XML file which contains general project settings, as well as the location to an Access database which contains other project related data. Over the years the format of the XML file has been modified, and an update and versioning strategy has been adopted. The chosen strategy performs an update upon open whenever an old version is encountered. Thus far, updates have only consisted of rearranging data within the XML file or making database schema changes and moving data from the XML file to the database.
Having quite a bit of background in OOP it's easy for me to see that a project should be a self contained object which other objects interact with. However, I fail to see how to apply the chosen update strategy in OOP.
The problem of implementing the chosen update strategy in OOP has kept me from using OOP as of yet. If anyone has experience with such a task, or recommendations on how to proceeded I'd appreciate any assistance you can provide.
Build a class which reads the XML file in, and provides properties/methods/etc based upon the data in that file. When the class writes the XML file back out, have it format in the manner needed for the new version.
So, basically, the class will be able to read in the current version, plus all the older versions, but it will always write out the new version.
Data would be held in internal variables of the class, rather than having to scan the XML file every time you need something.
Adding a VERSION node to your XML file will also help in this case.
You might have answered your own question when you used the word strategy (i.e. the Strategy Design Pattern).
Possibly you could:
Create a project class that knows nothing about conversions but accepts a strategy object.
Create a hierarchy of classes to model each possible conversion strategy.
Use a factory method to build your project object with the right strategy
I don't understand why this is a troubling problem. It could be solved in any number of ways.
If you want to do a full object oriented enterprisey type thing, you could take any subset of the following solution:
Create an interface IProject which
describes how other objects interact
with a project.
Create the current implementation of
Project which implements IProject
and can read and write to the
current version.
Extend Project for each past
version, overriding the xml and
database read methods and having the
constructor call write when these
classes are instanced
For extra enterpriseyness, create a
ProjectFactory, which detects the
version of the file and instanciates
the correct version.
If further versions are needed,
rewrite the current Project to do
the same thing as past projects,
accessing the new version of Project
with all the reads and then calling
write.
The advantage of this solution is that you can continue meandering about with different versions and each new version only requires the ability to be updated to from the previous version, with all previous versions cascading up to the second to last version.