Skip to main content

CUSTOM TYPES IN JAX WS

1 reply [Last post]
vitaliyse
Offline
Joined: 2011-02-22
Points: 0

Hi,

I want to write a service that accepts and returns a custom type

public class FooMessage {
private String text;
public String getText() {
return text;
}
public void setText(String message) {
this.text = message;
}
}

do I need to do anything special to use FooMessage to use it as a parameter for FooService?
@WebService(serviceName="fooService", portName="fooPort", targetNamespace="http://foo.not/jaxws")
public class FooService {
@WebMethod(action="messageAction")
public FooMessage echoMessage(FooMessage fooMessage){
return fooMessage;
}

}

I was using wsget in server project to generate code for service
after that I started service
and generated client code in client project.
When I use String as a parameter, everything is fine.
When I use FooMessage as parameter - I recieve
Feb 23, 2011 9:04:15 AM com.sun.xml.internal.ws.server.sei.EndpointMethodHandler invoke
SEVERE: argument type mismatch
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.xml.internal.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:235)
at com.sun.xml.internal.ws.server.InvokerTube$2.invoke(InvokerTube.java:135)
at com.sun.xml.internal.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:246)
at com.sun.xml.internal.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:82)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428)
at com.sun.xml.internal.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:232)
at com.sun.xml.internal.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:460)
at com.sun.xml.internal.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:233)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handleExchange(WSHttpHandler.java:95)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handle(WSHttpHandler.java:80)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:65)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:68)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:555)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:527)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)

Should I annotate FooMessage somehow to make it work as Web service parameter?
PS What book about JAX WS do you consider best?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ashutoshsjr
Offline
Joined: 2011-05-03
Points: 0

I am new to this and trying to use one custom object in my WS.IndexImpl is the class within the same package.But when i generate it via apt tool ,it is not able to compile saying... can not find sumbol class IndexImpl ...

Below is the code ..
@WebService
public class Main {
public static void main(String[] args) {
Endpoint endPoint = Endpoint.publish("http://localhost:8088/AppointWs", new Main());
}
@WebMethod
public void getData(String frequency){
processData(frequency);
}
private void processData(String frequency){
IndexImpl IndexImpl = new IndexImpl();
System.out.println("frequency :: " + frequency);
}