JAX/WS wsgen is not generating - web-services

I have a problem like this ; Could you please help me if you know the reason?
I m trying to generate jaxb classes for input and out types using wsgen command line utility.

The print screen you posted (and #home's comment is spot on - you should add the stacktrace not a print screen) tells you the problem.
#javax.jws.WebService annotated classes that do not belong to a package must have the #javax.jws.WebService.targetNamespace element.
You don't specify a target namespace and wsgen can't infer one because you classes are in the default package. Having classes in the default package is a frown upon practice. Put your classes under a package and try again or have the WebService.targetNamespace element set up which also gives you more control on what the tool generates.

#javax.jws.WebService the annotated classe who implements Web Service Business interface, must have a no-argument constructor otherwise wsGen tool gets such error.
Reference: Creating a Simple Web Service and Client with JAX-WS

Related

wsdl objects are repeated when I add webservice reference

when I add webservice reference (not a service reference), I am getting same element with renamed added suffix as 1 as shown in the image. this causes an error when I try to debug. Inner exception says
Message=Types 'service.AddressType1' and 'service.AddressType' both use the XML type name, 'AddressType', from namespace 'xxx'. Use XML attributes to specify a unique XML name and/or namespace for the type.
I understand the error and I already saw some different threads here those tell me that I should specify different namespace but I don't have AddressType1 defined anywhere in my proxy classes. I have only AddressType. where from do I get that AddressType1 or others?
Anyone else got that error? thanks for your help.
Have you looked at this answer? Inheriting Existing .Net Class Serialization Error
This answer also discusses issues with hierarchical namespacing (seems you may be doing that), so that may be your main issue: Classes in different sub-namespaces all appear at top level in WSDL
It appears that you may need to specify the XmlTypeAttribute. Can you provide your code sample for review?
I was having inherited proxy classes which I generated using xsd2code tool. Problem was that this tool generated namespaces correctly for the parent xsd classes but when I check the class in the child which is shared/common by other parent classes, It appears that namespace field was empty as below. Therefore my service reference had same properties/classes more than one time with 1 suffix as shown in the question. I have just added same namespace for those child/inherited classes, It worked fine and no repeated properties. I hope that this helps to someone else having similar problem.
System.Xml.Serialization.XmlRootAttribute([Namespace]:="", IsNullable:=True), _

Accessing 't' (from r18n) in a rack-unit test of a Sinatra app

When using sinatra-r18n to handle internationalisation, the r18n lib exposes a variable t for use within your helpers, routes and templates, as per these instructions.
I have written a simple unit test using rack-unit to confirm that some of my pluralisations work but the test throws an error claiming t is nil.
I've tried referencing it via app.t, MySillyApp.t (where MySillyApp is the name of my Sinatra app), MySillyApp.settings.t etc and none of them give me access to the t I need.
What I am trying to achieve is a confirmation that my translation files include all the keys I need corresponding to plurals of various metric units my app needs to understand. Perhaps there is a more direct way of testing this without going via the Sinatra app itself. I'd welcome any insight here.
I had similar task to check localized strings in my Cucumber scenarios.
I've made working example.
Here you can find how strings got translated.
This file halps to understand how to add R18n support to your testing framework:
require 'r18n-core'
...
class SinCucR18nWorld
...
include R18n::Helpers
end
As you can see instead of rack/unit I'm using RSpec/Cucumber, sorry.

Custom fields in WSDL for Cxf Webservice

I need to generate a custom wsdl from my java artifacts. I use cxf apis to generate service.
Let me describe the scenario in details,
I want to generate different WSDL from same set of java artifacts.The idea behind such requirement to is to provide license based operation/messages to the customers. We have set of java objects defined as messages and service interfaces/implementation. Using Cxf API (ServerFactoryBean) I generate Service/WSDL on demand( purely run time operation).
Just to make it clear, I am giving example scenario
public class InputBean {
private XYZ xyz;
private ABC abc;
private PQR pqr;
Where XYZ, ABC, PQR are some java objects and InputBean is used in my Service Implementation class.
The requirement is to have these fields conditionally based on license
if(XYZ Licensed){
Include XYZ in bean
}
if(PQR Licensed){
Include PQR in bean
}
if(XYZ and PQR licensed){
Inlcude XYZ and PQR
}
I know this is strange requirement, and not sure if I had explained my problem clearly.
I would have tried with inheritance(dynamic method dispatch), but I want random combinations.
Any help would be appreciated!
I have solved this issue by creating a template file(free marker template), with place holder for required classes. This will be substituted at run time with required class names, created java source files using free marker api and then created java classes by java compiler api. Also developed custom class loader to load the class at run time. All the operation will perform in background at runtime. I could not find a better solution for my requirement, but I am happy with this as it is giving perfect result as expected.

Is it possible to exclude Entity Framework Autogenerated Code from Code Coverage Statistics?

I have seen the [DebuggerNonUserCode] and [ExcludeFromCodeCoverage] attributes in resources and other SO questions about exlcuding code from coverage statistics, and wanted to know if it was possible to automatically add this attribute to the classes in the code generated by the Entity Framework using .NET 4.0.
Also would it need to be class level or could it be on the diagram.Designer.cs level, needing one attribute for all code generated by that diagram?
Since partial classes (which Entity Framework creates) merge attributes, extended functionality in other partial classes are also excluded if the attribute is class level in the template, it will have to be applied at the method level.
The best way that I've found to do this is using T4 (as recommended in #Craig Stuntz's answer) to:
include: using System.Diagnostics.CodeAnalysis; at the top of the file
Then apply [ExcludeFromCodeCoverage] to getters, setters and Factory methods by searching for:
#>get
#>set
Template_FactoryMethodComment
and placing them in the appropriate place.
This was made a lot easier using Tangible's T4 editor Extension for VS.
This is my first attempt and it seems to work, "your milage may vary", so complete a test run to make sure everything's working as necessary.

Multiple Grails scaffolding templates in one application

I'm creating a DB web application with grails for my company and found myself in the need to change the default scaffolding templates.
So far so good, everything gets generated with the modified templates (controllers, views, ..).
Now, however, I get a request to create some "composite screens" with functionalities and a layout that differ from the overwritten templates.
So now my question is: is it possible in grails to create one or more templates (next the the default one) and pass this template name as an argument to the generate-* commands?
Thanks in advance!
EDIT: Adding the template name to the generate commands was just an idea, if it's possible to do this a different way, I'll be happy too.
Grails commands are scripts in grails/scripts. If you follow its logic you will see two things.
1) There is only one parameter passed to the script → domain.
2) Class for generating views is DefaultGrailsTemplateGenerator. You can analyse sourcecode and check what this class offers.
Update
Link to DefaultGrailsTemplateGenerator in GitHub.
I am not sure about the generate command parameters, but if you add another .gsp page into scaffolding directory, I believe it will try to run it through generation process.
So for example I used to have a show.gsp page as well as showBasic.gsp page, which showed fewer properties.