19
I'm trying to send some entity to ejb based web service. Here is my web service client code:
package ejbserviceclient;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
public class EjbServiceClient {
public static void main(String[] args) throws MalformedURLException, JAXBException {
JAXBContext context = JAXBContext.newInstance(EjbServiceClient.class);
URL url = new URL("http://ipsedin:8080/WebServiceBeanService/WebServiceBean?wsdl");
QName serviceName = new QName(
"http://ejb.rpt.softcomputer.com/",
"WebServiceBeanService");
QName portName = new QName(
"http://ejb.rpt.softcomputer.com/",
"WebServiceBeanPort");
Service service = Service.create(url, serviceName);
Echo ejbService = service.getPort(portName, Echo.class);
System.out.println(ejbService.echo("lololo"));
System.out.println(ejbService.processExCourse(new ExCourse()));
}
}
And here is entity:
package ejbserviceclient;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class ExCourse {
int id;
}
But there is exception:
Exception in thread "main" javax.xml.ws.WebServiceException: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: class ejbserviceclient.ExCourse nor any of its super class is known to this context.]
at com.sun.xml.internal.ws.message.jaxb.JAXBMessage.writePayloadTo(JAXBMessage.java:318)
at com.sun.xml.internal.ws.message.AbstractMessageImpl.writeTo(AbstractMessageImpl.java:131)
at com.sun.xml.internal.ws.encoding.StreamSOAPCodec.encode(StreamSOAPCodec.java:98)
at com.sun.xml.internal.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:249)
at com.sun.xml.internal.ws.transport.http.client