how can JAXB2 directly use WSDL url instead of .WSDL file - soap

I have installed the JAXB2 maven plugin in my project.
The .WSDL file which generated from my SOAP WebService is located in the project directory, But I want JAXB2 to directly use WSDL URL instead of using the .wsdl file.

For maven-jaxb2-plugin see:
https://github.com/highsource/maven-jaxb2-plugin/wiki/Specifying-What-To-Compile
For WSDL it will be something like:
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<schemas>
<schema>
<url>https://www.acme.com/my.WSDL</url>
</schema>
</schemas>
</configuration>
schemaLanguage is optional, defaults to autodetection.
Having said this, I normally do not recommend compiling online resources unless you want your builds to fail unpredictably due to networking or HTTPS problems.
Instead, make a local copy and use catalog files to rewrite URLs.

Related

Why must the wsdl file be in WEB-INF (in Apache CXF)?

In the wsdl_first sample of Apache CXF the pom file puts the wsdl file in WEB-INF/. Also all the xml files and the wsdl file in src/main/resources ends up in WEB-INF/classes, because they are in src/main/resources.
I deploy the webapp in tomcat.
My question is: when I remove the wsdl file from WEB-INF and the xml files and the wsdl file from WEB-INF/classes (and restart Tomcat), the webapp still works. Why does the pom file put the wsdl file explicitly in WEB-INF? And why are the xml files and the wsdl file in WEB-INF/classes?
In src/main/webapp there are web.xml and cxf-servlet.xml. They end up in WEB-INF/. When I remove them, things go wrong.
So remember a WSDL is the official definition of a service interface. In other words if you want to create a client for a SOAP service you need a WSDL. You can use this WSDL to then generate code artifacts for the client. It is almost exactly similar to generating a server from a WSDL.
Now the WEB-INF folder is published and when the WSDL is in there it is published too. This will allow clients to get to the WSDL. However the WSDL is not needed for the service to run. Thus we can remove the WSDL.
You would typically remove the WSDL when you secure a service against public browsing. This will remove the ability for anyone just to get hold of the service definition.
Remember the WSDL is just a definition used to generate artefacts in various languages such as Java, .Net etc.
However it is not required for a SOAP server or client to run. Just for code generation.

Change web.xml after deployment

Is it advisable to change web.xml (or, in fact, any other file) in app server after the deployment? Do ALL app servers expose their deployment/directory structure?
I would prefer making changes locally, re-building the war (or .ear, etc.), and re-deploying the application.
Regarding your first question, it depends on the type of the resource. For a classpath resource, you can override the file in any directory that has a higher priority in the class loading mechanism of your application server ($CATALINA_HOME/lib for instance if you're using Tomcat). For an xml file, like web.xml, you can declare an external entity in the packaged file with an absolute path, but you have to be sure that the file will be present on the target server. For instance, your packaged web.xml could look like that:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document [
<!ENTITY webEntity SYSTEM 'C:\Temp\web.xml'>
]>
&webEntity;
So the actual content of the web.xml would be the content of the file C:\Temp\web.xml.
In short, there is no official way to do it but there are tricks. I guess, what people do is to produce a custom package for each production site. There are multiple ways to automate this with Maven like war overlay or classifiers. Here is an interesting link.
Regarding your second question, I would not rely on this assumption. It's quite straight-forward to modify an exploded resource on a Tomcat server but it's is not that simple on a JBoss AS.

Eclipse: Change webapp folder in Maven pom.xml file

Is it possible to define a different location for the webapp folder than the standard one ("/src/main/webapp/") in pom.xml? I know that you can define your web folder with
<wb-resource deploy-path="/" source-path="/webapp"/>
in a file called "org.eclipse.wst.common.component".
The problem is when I click Maven -> Update Project, this line is overwritten with the standard
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
And then I have problems testing my project with Tomcat7 within Eclipse.
I'm very thankful for every hint.
Answers in How to configure custom maven project structure are sufficient for a purely Maven build, i.e. from commandline. When import the project into Eclipse (via m2e), you need tell m2e a little bit more so that it can create and maintain the project structure properly within Eclipse.
Actually, from Eclipse's perspective, it doesn't really care about how your project folder structure looks like, as long as the webapp folder is declared as a source folder or inside a source folder, however, by modifying .classpath doesn't make much sense as it's a auto-generated file and changed quite often.
It is highly recommended to obey the convention if you are able to, if not, using the following configuration for your customization:
<build>
<resources>
<resource>
<directory>${basedir}/webapp</directory>
</resource>
... ...
</resources>
... ...
</build>

Eclipse - Wicket - HTML files from dependent projects not being found

I want to build a reusable Wicket component in Eclipse. I have one project "components" which have files such as MyComponent.java and MyComponent.html. Then I have a project "application" which contains my application code, from which I wish to use a MyComponent.
However, Wicket cannot find the MyComponent.html. If I copy this file from "components" to "application", and use exactly the same path, then Wicket finds it no problem.
I therefore summize that Eclipse is not copying the HTML file from the dependent project "components" and making it available to the web application. I cannot really confirm that as I don't know where the JAR is being generated from the "components" project, nor do I know where/if the WAR is being generated from the "application" project.
I have looked at the project settings in "components" and cannot find any option to explicitly publish HTML (non-Java) files when the project is being built; but I cannot find any option which is explicitly forbidding this either. In the "application" project I find no option to include HTML files from the other project (there is only the option to include the JAR - which potentially should be enough?)
Update: I am not using Maven, just using the default build process of Eclipse.
Update: I am using Tomcat within Eclipse (but without any Eclipse plug-in for Tomcat; it seems to work fine without it - only obviously that's not quite true hence my question...)
Check Eclipse's source folders inclusion/exclusion filters. Project -> right button -> Properties -> Java Build path -> tab Source -> select Source Folder -> button Edit.
I'm assuming you're using Tomcat - during testing I normally use a Tomcat context to reference my Eclipse project workspace.
The workspace contains a context/WEB-INF directory structure, into which all my compiled classes, properties, HTML and other resources are copied.
The Tomcat context file lives in the directory (Tomcat)/conf/Catalina/localhost and contains an entry of the following format:
<Context path="/mywebapp" docBase="C:/eclipse/workspace/myapp/context" reloadable="true">
OK - Classic Eclipse action - for other reasons (restarting the project always resulted in a 404 for no apparent reason: I checked all the config files and everything seemed fine..), I deleted the "application" project from Eclipse and re-created it. Now everything works fine (HTML files are available...)
I had the same problem! After some time doing research I had a solution!
You need to specify to maven that it needs to include all the files, the way how maven understand this is by adding the next command.
<build>
<resources>
<resource>
<filtering>false</filtering>
<directory>src/main/resources</directory>
</resource>
<resource>
<filtering>false</filtering>
<directory>src/main/java</directory>
<includes>
<include>**</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
</build>
It worked for me, I hope it works for any of you that have the same problem!
I guess for the person that posted this query its too late, but not for you that have this problem!

Eclipse Checkstyle with configuration and SuppressionFilter on server

I have configured my Eclipse to use a remote checkstyle configuration that is located on a server, which I reach via HTTP. This works fine, but the configuration contains:
<module name="SuppressionFilter">
<property name="file" value="${basedir}/checkstyle-filter.xml"/>
</module>
So I try to set an additional property "basedir" which points to the same directory where the configuration is. When I try to run checkstyle on a project I get an error: cannot initialize module SuppressionsFilter - Cannot set property 'file' in module SuppressionFilter to 'http://"my Url "/checkstyle-filter.xml'
Any suggestions on how to configure Eclipse to use the checkstyle configuration from the server even though it has that it contains the SuppressionFilter? I do not want to put a checkstyle-filter in each project...
This is currently not possible as reported in Remote Configuration Files cannot use a SuppressionFilter - ID: 2018081. Actually, the problem is in Checkstyle which uses a java.io.File object for the external SuppressionFilter file (and thus setting a value starting with http:// won't work). There is a feature request on Checkstyle to change this (see Allow remote references to additional file configuration - ID: 2018608). But don't expect these changes to occur very soon (unless if you start working hard on it :)
That being said, while I perfectly understand the need for a corporate wide checkstyle configuration file, I'm more surprised by the need for a shared SuppressionFilter file. After all, its content is project specific, isn't it? So, I think that you should actually use another property, for example ${workspace} (or your own property, my understanding of Expanding property placeholders is that using a .properties file is supposed to work with a Remote Configuration too) and ask each project to provide its own file with its SuppressionFilter that would be referenced from the workspace. Based on convention, that should work.
Actually, you can use a suppression filter. I have it setup this way with a remote config using the 5.6 eclipse checkstyle plugin. Just put the suppression file in the same remote directory as the checkstyle.xml file and then use the following:
<property name="file" value="${config_loc}/suppression.xml" />
It will then work with eclipse. Basically just replace ${base_dir} with ${config_loc}
I wasn't able to add a patch to the original feature request, so I created a new feature request here: https://sourceforge.net/tracker/?func=detail&atid=397081&aid=3485185&group_id=29721
I've implemented this functionality as I needed it to be able to corporate-wide disable certain checks for unit tests and Eclipse-generated NLS classes.
I've tested it with the 5.5 version of eclipse-cs by patching the jar file for the plugin and it works quite well.