1. I did do something wrong:
Object EncodeRequestType =
Thread.currentThread().getContextClassLoader().loadClass("be.smals.ehealth.codage.beans.OriginalDataType").newInstance();
has to be:
Object EncodeRequestType =
Thread.currentThread().getContextClassLoader().loadClass("be.smals.ehealth.codage.beans.EncodeRequestType").newInstance();
2. I changed the whole code:
//OriginalDataType
Object OriginalDataType =
Thread.currentThread().getContextClassLoader().loadClass("be.smals.ehealth.codage.beans.OriginalDataType").newInstance();
Method d = OriginalDataType.getClass().getMethod("setId",
String.class);
d.invoke(OriginalDataType, "1");
Method d2 =
OriginalDataType.getClass().getMethod("setRandomize", Boolean.class);
d2.invoke(OriginalDataType, false);
Method d3 =
OriginalDataType.getClass().getMethod("setInputData", String.class);
d3.invoke(OriginalDataType, "Ik ben gek");
//EncodeRequestType
Object EncodeRequestType =
Thread.currentThread().getContextClassLoader().loadClass("be.smals.ehealth.codage.beans.EncodeRequestType").newInstance();
Method m =
EncodeRequestType.getClass().getMethod("setApplicationName", String.class);
m.invoke(EncodeRequestType, "WWM");
But this gives errors to:
A. Method d2 = OriginalDataType.getClass().getMethod("setRandomize",
Boolean.class);
Gives error:
java.lang.NoSuchMethodException:
be.smals.ehealth.codage.beans.OriginalDataType.setRandomize(java.lang.Boolean)
at java.lang.Class.getMethod(Class.java:1605)
at cxfehealth.Main.main(Main.java:49)
This is strange, because the method 'setId' has no errors, but is in the
same contect!
B. Object EncodeRequestType =
Thread.currentThread().getContextClassLoader().loadClass("be.smals.ehealth.codage.beans.EncodeRequestType").newInstance();
Gives error:
java.lang.ClassNotFoundException:
be.smals.ehealth.codage.beans.EncodeRequestType
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at cxfehealth.Main.main(Main.java:55)
That is also strange, because it finds the precedent class
'OriginalDataType': why it doesn't find EncodeRequestType?
C. After that, I've to integrate OriginalDataType in EncodeRequestType ...
Sincerely,
Koen
2011/2/21 Koen Thomeer <[email protected]>
> The WSDL is: http://wwwacc.ehealth.fgov.be/codage_1_0/codage?WSDL
>
> Koen
>
> 2011/2/21 Koen Thomeer <[email protected]>
>
> Hello,
>>
>> I've to admit: I'm a beginning Java Developer. I'm comming from the PHP
>> world.
>>
>> Can someone help me: I get this error:
>>
>>> java.lang.NoSuchMethodException:
>>> be.smals.ehealth.codage.beans.OriginalDataType.setApplicationName(java.lang.String)
>>> at java.lang.Class.getMethod(Class.java:1605)
>>> at cxfehealth.Main.main(Main.java:47)
>>>
>>
>> Thx,
>>
>> Koen
>>
>>
>> package cxfehealth;
>>
>> import org.apache.log4j.BasicConfigurator;
>> import org.apache.log4j.Logger;
>> import org.apache.log4j.Level;
>> import org.apache.ws.security.handler.WSHandlerConstants;
>> import org.apache.cxf.endpoint.dynamic.DynamicClientFactory;
>> import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
>> import org.apache.cxf.endpoint.Client;
>> import java.util.HashMap;
>> import java.util.Map;
>> import java.io.File;
>> import java.net.URL;
>> import java.lang.reflect.Method;
>>
>> /**
>> *
>> * @author Koen Thomeer, MD, http://koen.thomeer.be
>> */
>> public class Main {
>>
>> /**
>> * @param args the command line arguments
>> */
>> public static void main(String[] args) {
>> try {
>> // configure logging
>> BasicConfigurator.configure();
>> Logger.getLogger("org").setLevel(Level.WARN);
>>
>> java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.WARNING);
>> // point to private wdsl
>> URL wsdlURL;
>> File wsdlFile = new File("src/codage.wsdl");
>> wsdlURL = wsdlFile.toURL();
>> System.out.println(wsdlURL);
>> // use CXF dynamic clients
>> DynamicClientFactory dcf = DynamicClientFactory.newInstance();
>> ClassLoader classloader =
>> Thread.currentThread().getContextClassLoader();
>> Client client = dcf.createClient(wsdlURL, classloader);
>> Object EncodeRequestType =
>> Thread.currentThread().getContextClassLoader().loadClass("be.smals.ehealth.codage.beans.OriginalDataType").newInstance();
>> //System.out.println(EncodeRequestType);
>> Method m =
>> EncodeRequestType.getClass().getMethod("setApplicationName", String.class);
>> m.invoke(EncodeRequestType, "WWM");
>>
>>
>> // 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",
>> EncodeRequestType)[0]);
>> } catch (Exception ex) {
>> ex.printStackTrace();
>> }
>> }
>> }
>>
>>
>> --
>> *Koen Thomeer*, MD, MSc
>> http://koen.thomeer.be
>>
>
>
>
> --
> *Koen Thomeer*, MD, MSc
> http://koen.thomeer.be
>
--
*Koen Thomeer*, MD, MSc
http://koen.thomeer.be