JAX-WS Client

Error

Caused by: java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j

Solution

Add -Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.SLF4JLogFactory

to VM arguments when running main.

Error

org.apache.axis2.AxisFault: WSWS7130E: No Secure Sockets Layer (SSL) configuration is available

Solution

Section Issue with Using IBM’s JAX-WS runtime at the below link

http://btarlton.blogspot.com/2013/03/ever-have-trouble-using-ssl-to-call-web.html

 

Error

org.apache.commons.discovery.DiscoveryException: No implementation defined for org.apache.commons.logging.LogFactory

Download jars from Apache Commons Logging and add to classpath

https://commons.apache.org/proper/commons-logging/download_logging.cgi

 

Set Basic Auth

//basic auth
BindingProvider bp = (BindingProvider)proxy._getDescriptor().getProxy();
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, “username”);
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, “password”);

 

Print certain element as XML

https://stackoverflow.com/questions/2461232/jaxb-entity-print-out-as-xml

public String toXml(JAXBElement element) {
    try {
        JAXBContext jc = JAXBContext.newInstance(element.getValue().getClass());  
        Marshaller marshaller = jc.createMarshaller();  
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);  

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        marshaller.marshal(element, baos);
        return baos.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }      
    return "";
}

Print entire response XML

public void toXml() {
    try {
        JAXBContext ctx = JAXBContext.newInstance(User.class);
        Marshaller marshaller = ctx.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        marshaller.marshal(this, System.out);
    }
    catch (Exception e) {
    e.printStackTrace();
    }
}

Call it like:

log.info("Customers sent: "+user.toXml());

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.