Displaying keyword search results 1 - 10
Created by Dr. Xi on June 04, 2014 16:56:56 Last update: June 04, 2014 16:56:56
The error was something like this:
Simple type "ExtraLongEnumListType" was not mapped...Solution: create a binding file to increase the EnumMemberSizeCap limit. The POM file:
<dependency> <groupId>org.apach...Contents of bindings.xml :
Created by Fang on January 10, 2014 14:07:20 Last update: January 10, 2014 14:07:20
An example project with Spring MVC and Apache Tiles. List of files:
./pom.xml ./src/main/webapp/WEB-INF/web.xml..../pom.xml :
<?xml version="1.0" encoding="UTF-8"?> <pro..../src/main/webapp/WEB-INF/web.xml :
<?xml version="1.0" encoding="UTF-8"?> <web-app..../src/main/webapp/WEB-INF/applicationContext.xml :
<?xml version="1.0" encoding="UTF-8"?> <beans x..../src/main/webapp/WEB-INF/spring-servlet.xml :
<?xml version="1.0" encoding="UTF-8"?> <beans x..../src/main/webapp/WEB-INF/tiles-definitions.xml :
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYP..../src/main/webapp/WEB-INF/jsp/template.jsp :
<!DOCTYPE html> <%@ page pageEncoding="UTF-8" %..../src/main/java/com/example/MyController.java :
package com.example; import javax.servlet.S...
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......
Jaxb binding file to generate java.util.Calendar instead of javax.xml.datatype.XMLGregorianCalendar for xs:dateTime
Created by Dr. Xi on March 21, 2013 20:33:18 Last update: March 21, 2013 20:33:18
This is a jaxb binding file that generates java.util.Calendar for xs:dateTime :
<?xml version="1.0" encoding="UTF-8" standalone="y...
Created by Fang on March 30, 2012 10:07:25 Last update: March 08, 2013 13:41:57
After a user resets a password, I want to force the user to change the password before she gets access to secured content. This is usually done with a servlet filter. But with Spring MVC, you can also use a HandlerInterceptor . According to Spring JavaDoc: HandlerInterceptor is basically similar to a Servlet 2.3 Filter, but in contrast to the latter it just allows custom pre-processing with the option of prohibiting the execution of the handler itself, and custom post-processing. Filters are more powerful, for example they allow for exchanging the request and response objects that are handed down the chain. Note that a filter gets configured in web.xml, a HandlerInterceptor in the application context. As a basic guideline, fine-grained handler-related preprocessing tasks are candidates...
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 Dr. Xi on October 08, 2012 11:56:29 Last update: October 08, 2012 11:56:29
This example gets the annotation attributes of of a web service client generated by JAX-WS RI. The generated web service client looks like this:
import javax.xml.ws.Service; import javax.xml.w...This is how to get the attributes for annotation @WebServiceClient :
WebServiceClient wsc = MyTestWebService.class.getA...Note that even though name , targetNamespace and wsdlLocation are attributes, you get them using a method call. Also, annotations are available at runtime only when they have RetentionPolicy.RUNTIME .
Created by Fang on July 25, 2012 12:52:40 Last update: September 14, 2012 13:37:57
Summarized from official JAX-WS documentation : Sending and Receiving SOAP Headers To send a SOAP header:
HelloService helloService = new HelloService(); ...To receive a SOAP header:
List<Header> inboundHeaders = bp.getInboundHeaders...Message logging On the client side, set system property:
com.sun.xml.ws.transport.http.client.HttpTransport...On the server side, set system property:
com.sun.xml.ws.transport.http.HttpAdapter.dump=tru...Propagation of Server-side Stacktrace Propagation of Stack trace is on by default. The whole stacktrace (including nested exceptions) is propagated in the SOAP Fault and the complete exception stacktrace is visible to the client as cause of SOAPFaultException . To turn off stack trace propagation, set this system property on the server:
com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptu...Update: At least on the client side, the property name has been changed to:
com.sun.xml.internal.ws.transport.http.client.Http...The messages are dumped to stdout . For...