Displaying keyword search results 1 - 10
Created by Dr. Xi on March 22, 2013 12:18:39 Last update: March 22, 2013 12:18:39
This is a step-by-step guide to create a "contract-first" web service with Apache CXF. It's a lot easier than doing the same thing with Spring-WS. The project uses standard Maven directory layout. Define the data types ( src/main/resources/hello.xsd ):
<xs:schema xmlns:xs="http://www.w3.org/200...Define the service ( src/main/resources/hello.wsdl ):
<?xml version='1.1' encoding='UTF-8'?> <wsdl:de...Create pom.xml :
<project xmlns="http://maven.apache.org/POM/4....Generate jaxb bindings:
$ mvn generate-sourcesCode the web service ( src/main/java/com/example/cxfdemo/HelloPortImpl.java ):
package com.example.cxfdemo; import javax.j...Declare the CXF servlet in web.xml ( src/main/webapp/WEB-INF/web.xml ):
<?xml version="1.0" encoding="UTF-8"?> <web-app...Wire up the web service implementation ( src/main/webapp/WEB-INF/cxf-servlet.xml ):
<?xml version="1.0" encoding="UTF-8"?> <beans x...Build the WAR:
$ mvn clean packageAfter the webapp is deployed (Tomcat running on port 8080), the web service (WSDL) is available via...
Created by Dr. Xi on March 21, 2013 20:29:14 Last update: March 22, 2013 08:58:08
Spring-WS documentation says you can use a Jaxb object as parameter or return type, provided that it is annotated with javax.xml.bind.annotation.XmlRootElement , or is an instance of javax.xml.bind.JAXBElement . But that's a lot easier said than done! For example, if sayHelloResponse is defined as:
<xs:element name="sayHelloResponse" type="tns:sayH...then the JAXB generated class is not annotated with XmlRootElement , therefore, unusable for Spring-WS. You have to define the type as:
<xs:element name="sayHelloResponse"> <xs:compl...in order to generate a type annotated with XmlRootElement . But that is not always possible. Alternatively, you can use the Maven plugin maven-jaxb2-plugin with the jaxb2-basics-annotate plugin (yes, plugin inside plugin) to inject the XmlRootElement annotation into the generated JAXB class. This is the pom:
<project xmlns="http://maven.apache.org/POM/4.0.0"...and the binding file:
<?xml version="1.0" encoding="UTF-8" standalone="y......
Created by Dr. Xi on March 07, 2013 20:26:23 Last update: March 07, 2013 20:26:23
Create a jax-ws web service with Spring, Apache CXF and Maven. Create the pom.xml :
<project xmlns="http://maven.apache.org/POM/4.0.0"...Create the web service interface ( src/main/java/jaxws/JaxwsHello.java ):
package jaxws; import javax.jws.WebService;...Implement the web service ( src/main/java/jaxws/JaxwsHelloImpl.java ):
package jaxws; import javax.jws.WebService;...Create src/main/webapp/WEB-INF/cxf-servlet.xml :
<?xml version="1.0" encoding="UTF-8"?> <beans x...Register the CXF servlet in src/main/webapp/WEB-INF/web.xml :
<?xml version="1.0" encoding="UTF-8"?> <web-app...Build:
mvn packageThe resulting WAR file can be deployed to any servlet container (for example, Tomcat).
Created by Dr. Xi on March 01, 2013 16:09:00 Last update: March 04, 2013 12:28:23
This is probably the easiest way to create a web service in JAX-WS. There are no external dependencies other than Java EE. Assuming that you build the web service as a webapp (say jaxws-example.war), the pom.xml can be as simple as:
<project xmlns="http://maven.apache.org/POM/4.0.0"...You can implement and deploy the web service in 3 easy steps: Code the service as a POJO (annotate class to expose it as a web service)
package jaxws; import javax.jws.WebMethod; ...Declare the POJO as a servlet in WEB-INF/web.xml :
<?xml version="1.0" encoding="UTF-8"?> <web-app...Build the webapp, and deploy the resulting war:
mvn packageThe only catch is, this only works for a Java EE 5+ compliant container such as WebLogic or JBoss. It does not work for a simple servlet...
Created by Fang on January 04, 2013 14:35:14 Last update: January 04, 2013 14:35:41
You can use the runOrder parameter to control the test execution order for Maven surefire tests:
<build> <plugins> <plugin> ...Other options are: Option Meaning alphabetical Alphabetical reversealphabetical Reverse Alphabetical random Randomized hourly alphabetical on even hours, reverse alphabetical on odd hours failedfirst Failed first will run tests that failed on previous run first, as well as new tests for this run. balanced Balanced is only relevant with parallel=classes, and will try to optimize the run-order of the tests to make all tests complete at the same time, reducing the overall execution time. filesystem This is the default. I guess this is the order returned by the file system: uncontrolled but deterministic.
Created by Fang on January 04, 2013 09:02:44 Last update: January 04, 2013 09:02:44
This snippet sets system properties from Maven surefire test plugin. This is useful when you want to set logging (for example, log4j) properties based on Maven project properties. Example that sets system property testlog.dir :
<plugins> <plugin> <groupId>org.apach...Example log4j.xml that uses system property testlog.dir :
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYP...
Created by Fang on January 04, 2013 08:00:37 Last update: January 04, 2013 08:00:37
This is a Maven POM that prints out some built-in project properties:
$ mvn validate [INFO] Scanning for projects.....
Created by Fang on June 05, 2012 09:12:36 Last update: June 05, 2012 09:13:03
The apache.commons.lang package has a nice utility to escape strings for various language environments. Simply include the dependency in pom.xml :
<dependency> <groupId>org.apache.commons</...and use it:
// import org.apache.commons.lang3.StringEscapeUti...
Created by Dr. Xi on May 25, 2012 21:13:11 Last update: May 25, 2012 21:13:11
I learned this the hard way. Apache is set up and running fine. I can open the "It works!" page in a local browser. I added the rules to the Windows Firewall to allow incoming connection from both Private and Public networks. But when I tried to access the default Apache page from another PC, timeout! I removed the rules, added them back again, double checked, still timeout! I then removed the firewall rules and used Windows 7 troubleshooting tool to fix the problem. It correctly identified and "fixed" the problem. But I still get timeout! Finally I got tired of all this and hit the Power button. It worked! Everything worked out after reboot! Lesson learned: Windows 7 is still Windows.
Created by Dr. Xi on May 25, 2012 15:47:34 Last update: May 25, 2012 15:49:33
Steps to configure SSL for Apache HTTPD server on Windows: In Apache2.2/conf/httpd.conf , load mod_ssl and include httpd-ssl.conf :
LoadModule ssl_module modules/mod_ssl.so ...In Apache2.2/conf/extra/httpd-ssl.conf , make sure the paths for the cert files point to the cert and key you want to use:
# Server Certificate: # Point SSLCertificat...Start up Apache. If it fails, use the command line to see what the error is. There won't be any log in error.log if there are errors in the conf files:
C:\Program Files (x86)\Apache Software Foundation\...I corrected the previous error by using the alternative line for SSLSessionCache :
# Inter-Process Session Cache: # Configure ...