How can I use an HTTP proxy for a JAX-WS request without setting a system-wide property?

I recommend using a custom ProxySelector. I had the same problem and it works great and is super flexible. It’s simple too. Here’s my CustomProxySelector: import org.hibernate.validator.util.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.*; import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; /** * So the way a ProxySelector works is that … Read more

How to make generated classes contain Javadoc from XML Schema documentation

I’ve never been able to get regular xsd:documentation to be placed in the java source except if and only if it was a Complex Type. Documentation for elements, simple types, etc are ignored. So, I end up using jxb:javadoc. To do so, include the definition of xmlns:jxb=”http://java.sun.com/xml/ns/jaxb” in your <xsd:schema> element. Add a child to … Read more

overriding or setting web service endpoint at runtime for code generated with wsimport

Your client can set the end-point in the service “port” at runtime via the BindingProvider interface. Consider the JAX-WS client in this JAX-WS tutorial. Another way to write this code would be: HelloService service = new HelloService(); Hello port = service.getHelloPort(); BindingProvider bindingProvider = (BindingProvider) port; bindingProvider.getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, “http://foo:8086/HelloWhatever”); String response = port.sayHello(name); Caveat: I … Read more

JAX-WS = When Apache CXF is installed it “steals” default JDK JAX-WS implementation, how to solve?

Apache CXF (cxf-rt-frontend-jaxws-*.jar to be precise) registers itself as a JAX-WS provider in the JVM. Inside the aforementioned JAR there is a file named: /META-INF/services/javax.xml.ws.spi.Provider with the following contents: org.apache.cxf.jaxws.spi.ProviderImpl If you now look at javax.xml.ws.spi.FactoryFinder#find method you will discover that JDK searches the CLASSPATH for the presence of javax.xml.ws.spi.Provider file and falls back to … Read more

JAX-WS Loading WSDL from jar

Yes this is most definitely possible as I have done it when creating clients through javax.xml.ws.EndpointReference, a WS-A related class. I have added a classpath reference to the WSDL to the WS-A EndPointReference and the Metro implementation of JAX-WS loaded it just fine. Whether loading the WSDL from the WS-A EndPointReference or from a file … Read more

java: Rpc/encoded wsdls are not supported in JAXWS 2.0

RPC/encoded is a vestige from before SOAP objects were defined with XML Schema. It’s not widely supported anymore. You will need to generate the stubs using Apache Axis 1.0, which is from the same era. java org.apache.axis.wsdl.WSDL2Java http://someurl?WSDL You will need the following jars or equivalents in the -cp classpath param: axis-1.4.jar commons-logging-1.1.ja commons-discovery-0.2.jar jaxrpc-1.1.jar … Read more

Unable to create JAXBContext creating my wsdl

Throwable objects (that means exceptions and errors) can’t be transferred directly, because they can’t be serialized to XML (the StackTraceElement doesn’t have a no-arg constructor, which is required by JAXB). You have to use SOAP faults for that. See this question. It points you to the @WebFault annotation which you should put on your exception … Read more