Skip to main content

Custom class in a Web Servcie Client

1 reply [Last post]
joshuadev
Offline
Joined: 2009-02-23

Suppose we have a web service:

@WebService
public class TestWs {

@WebMethod
public void test(Foo foo) {
...
}
}

and a Foo class:

public class Foo {

private String message;

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

}

Is this possible to use THIS Foo class in a web service client instead of that one generated by a wsimport task? I mean that I want to generate client service (WebServiceClient) with the wsimport task but it should use my implementation of the Foo class.
Thanks for help!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
woel
Offline
Joined: 2007-09-06

Yes it is.

Create static binder methods that take a string and return a Foo and the other way. Then declare a custom type binding in an xjb file.

parseMethod="package_name.CustomFooBinder.fromString"
printMethod="package_name.CustomFooBinder.toString" />

There probably plenty of examples available on the web. Good luck!

I'm not sure about complex types though...

Message was edited by: woel