Dynamic WebService implementation
Posted
by chardex
on Stack Overflow
See other posts from Stack Overflow
or by chardex
Published on 2010-03-25T10:14:17Z
Indexed on
2010/03/28
15:53 UTC
Read the original article
Hit count: 145
I have a set of different interfaces and I need to give them access via web services.
I have implemented this task in .NET as follows: dynamically generated interface implementation on the IL, marked methods with WebMethod annotation, and in *.asmx handler called generated stub.
More needs to be able to change the method signatures (eg change the type of certain argument or add new arguments), ie not always explicitly implement an interface, and use it as a decorator pattern.
Example:
interface ISomeService {
void simpleMetod (String arg1);
void customMetod (CusomType arg1, Integer arg2);
}
// Need to dynamically generate such class
@WebService
class SomeWebService {
private ISomeService someService = new SomeServiceImpl ();
@WebMethod
public void simpleMethod (String arg1) {
someService.simpleMethod (arg1);
}
@WebMethod
public void customMethod (String arg1, Integer arg2) {
someService.customMethod (CusomType.fromString (arg1), arg2);
}
}
Interfaces such as ISomeService quite a lot. And manually write code like this I don't want.
I work with Java recently, what technology/libraries should be used to solve such task.
Thanks.
© Stack Overflow or respective owner