Hi,
I think we need to hava an FAQ for these kind of issues.
Tuscany treats POJO as JAXB for the XML serialization/deserialization. JAXB has
a set of default rules that map java properties to XML elements. The simplest
case is to use JavaBeans to represent the data. Interfaces cannot be directly
supported unless you use the techniques described in [1].
In your case, your Employee class can look like:
public class Employee
{
public String name=""; // You can use setter/getter pattern too
public String id="";
public String exportValue( String nameid ){
return nameid;
}
public Object importValue( String name, String id ){
this.name=name; this.id=id; return name+id;
}
}
[1] https://jaxb.dev.java.net/guide/Mapping_interfaces.html
Thanks,
Raymond
From: Tuscany User
Sent: Thursday, February 12, 2009 8:50 PM
To: [email protected]
Subject: IllegalAnnotationsException - exposing soap service
Hi all,
I was trying a simple calculator soap service and ran into the following
exception. Please suggest on what can be done to overcome this exception.
SEVERE: Exception thrown was: org.osoa.sca.ServiceRuntimeException:
com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of
IllegalAnnotationExceptions com.samples.simpleCalculatorSOAP.EmployeeInterface
is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at com.samples.simpleCalculatorSOAP.EmployeeInterface
at public com.samples.simpleCalculatorSOAP.EmployeeInterface
com.samples.simpleCalculatorSOAP.Employee1.getEmployeeInterface()
at com.samples.simpleCalculatorSOAP.Employee1
com.samples.simpleCalculatorSOAP.EmployeeInterface does not have a no-arg
default constructor.
this problem is related to the following location:
at com.samples.simpleCalculatorSOAP.EmployeeInterface
at public com.samples.simpleCalculatorSOAP.EmployeeInterface
com.samples.simpleCalculatorSOAP.Employee1.getEmployeeInterface()
at com.samples.simpleCalculatorSOAP.Employee1
The class that is exposed as soap service is as below.
package com.samples.simpleCalculatorSOAP;
import org.osoa.sca.annotations.Remotable;
@Remotable
public class SimpleCalculatorServiceImpl extends
SimpleCalculatorServiceImplBase {
public String add(double n1, double n2){
Double temp = n1+n2; return temp.toString();
}
public String subtract(double n1, double n2){
Double temp = n1-n2; return temp.toString();
}
public String multiply(double n1, double n2){
Double temp = n1*n2; return temp.toString();
}
public String divide(double n1, double n2){
Double temp = n1/n2; return temp.toString();
}
}
The definition of the remaining classes/interfaces is as below.
---------------------------------------------------------------------------------------
package com.samples.simpleCalculatorSOAP;
public class SimpleCalculatorServiceImplBase {
public final void setEmployee1(Employee1 e){
System.out.println(e.getId()+" "+e.getName());
}
}
---------------------------------------------------------------------------------------
package com.samples.simpleCalculatorSOAP;
public final class Employee1 {
private EmployeeInterface ei = null;
public void setEmployeeInterface(EmployeeInterface e){
this.ei=e;
}
public EmployeeInterface getEmployeeInterface(){
return ei;
}
}
---------------------------------------------------------------------------------------
package com.samples.simpleCalculatorSOAP;
public interface EmployeeInterface {
public String exportValue( String nameid );
public Object importValue( String name, String id );
}
---------------------------------------------------------------------------------------
package com.samples.simpleCalculatorSOAP;
public class EmployeeImpl implements EmployeeInterface
{ private String name=""; private String id="";
public String exportValue( String nameid ){
return nameid;
}
public Object importValue( String name, String id ){
this.name=name; this.id=id; return name+id;
}
}
---------------------------------------------------------------------------------------
The example does not make sense on the implementation stand point, I mean
we are looking into the calculator implementation and then we have some piece
that talks about Employee. I was not looking to get this sample right, this
sample was meant for experimenting a few things and then hit the
IllegalAnnotationsException. Please suggest what annotations have to be added
to make this sample working. It would be great if you guys can added the
annotations in the above pseudo code itself to make this sample working. By
working I mean atleast deploying since I am hitting the issue while deploying
this app.
Thanks.