This is the code:
public class JavaCodage {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try {
// configure logging
BasicConfigurator.configure();
Logger.getLogger("org").setLevel(Level.WARNING);
java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.WARNING);
// use CXF dynamic clients
JaxWsDynamicClientFactory dcf =
JaxWsDynamicClientFactory.newInstance();
File file = new File("codage.wsdl");
URL url = file.toURL();
Client client = dcf.createClient(url);
//OriginalDataType2
OriginalDataType ODT = new OriginalDataType();
ODT.setId("1");
ODT.setRandomize(false);
ODT.setInputData("Ik ben gek");
//EncodeRequestType2
EncodeRequestType ERT = new EncodeRequestType();
ERT.setApplicationName("WWM");
ERT.getOriginalData().add(ODT);
// configure security settings
Map<String, Object> props = new HashMap<String, Object>();
props.put(WSHandlerConstants.ACTION, "Timestamp Signature");
props.put(WSHandlerConstants.TTL_TIMESTAMP, "15");
props.put(WSHandlerConstants.USER, "wwm_eh_key");
props.put(WSHandlerConstants.PW_CALLBACK_CLASS,
ClientCallbackHandler.class.getName());
props.put(WSHandlerConstants.SIG_PROP_FILE,
"client_sign.properties");
props.put(WSHandlerConstants.SIGNATURE_PARTS, "{Element}{
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;Token;{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body
");
props.put(WSHandlerConstants.SIG_KEY_ID, "DirectReference");
client.getEndpoint().getOutInterceptors().add(new
WSS4JOutInterceptor(props));
// call the WebService
System.out.println(client.invoke("encode",ERT)[0]);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Looking at Wireshark, the XML response is perfect, but:
WARNING: Interceptor for {
http://www.ehealth.be/webservices/cod}Codage#{http://www.ehealth.be/webservices/cod}encodehas
thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unmarshalling Error:
be.smals.ehealth.codage.beans.EncodeResponse is not known to this context
at
org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:798)
at
org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:632)
at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:133)
at
org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:198)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:755)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2335)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2193)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2037)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:697)
at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:516)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:285)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:271)
at javacodage.JavaCodage.main(JavaCodage.java:62)
--
*Koen Thomeer*, MD, MSc
http://koen.thomeer.be