I have inserted the two java classes from wsdl2java.
2011/2/21 Koen Thomeer <[email protected]>
> 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
>
--
*Koen Thomeer*, MD, MSc
http://koen.thomeer.be
package be.smals.ehealth.codage.beans;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for EncodeRequestType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="EncodeRequestType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="applicationName" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="originalData" type="{http://beans.codage.ehealth.smals.be/}OriginalDataType" maxOccurs="unbounded"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "EncodeRequestType", propOrder = {
"applicationName",
"originalData"
})
public class EncodeRequestType {
@XmlElement(required = true)
protected String applicationName;
@XmlElement(required = true)
protected List<OriginalDataType> originalData;
/**
* Gets the value of the applicationName property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getApplicationName() {
return applicationName;
}
/**
* Sets the value of the applicationName property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setApplicationName(String value) {
this.applicationName = value;
}
/**
* Gets the value of the originalData property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the originalData property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getOriginalData().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link OriginalDataType }
*
*
*/
public List<OriginalDataType> getOriginalData() {
if (originalData == null) {
originalData = new ArrayList<OriginalDataType>();
}
return this.originalData;
}
}
package be.smals.ehealth.codage.beans;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for OriginalDataType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="OriginalDataType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="id" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="randomize" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* <element name="inputData" type="{http://www.w3.org/2001/XMLSchema}string"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "OriginalDataType", propOrder = {
"id",
"randomize",
"inputData"
})
public class OriginalDataType {
@XmlElement(required = true)
protected String id;
protected boolean randomize;
@XmlElement(required = true)
protected String inputData;
/**
* Gets the value of the id property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getId() {
return id;
}
/**
* Sets the value of the id property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setId(String value) {
this.id = value;
}
/**
* Gets the value of the randomize property.
*
*/
public boolean isRandomize() {
return randomize;
}
/**
* Sets the value of the randomize property.
*
*/
public void setRandomize(boolean value) {
this.randomize = value;
}
/**
* Gets the value of the inputData property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getInputData() {
return inputData;
}
/**
* Sets the value of the inputData property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setInputData(String value) {
this.inputData = value;
}
}