Discussion:
Making async interfaces manually with annotations etc?
Kent Närling
2011-08-17 08:23:26 UTC
Permalink
Hi!

We declare our SOAP interfaces in java and then build the WSDL:s from the
java code since 99% of our clients are in java and to make it most
convenient for them we have decided to follow this path.

eg we might have a sample service declared like:

@WebService

public interface MyService

{

@WebMethod(operationName = "doSomething")

DoSomethingResult doSomething(

@WebParam(name = "someParam") String someParam);

}


Now, we could like to be able to call this using the async way with
callbacks, is there some way we can declare this manually with annotations?
(ie without generating the code from wsdl)

And would it then be possible to JUST declare the callback variations, since
we know we won't use the polling approach etc?

Thanks
/Kent
Kent Närling
2011-08-17 14:17:58 UTC
Permalink
I tried ad-hoc and just wrote the interface myself as:

@WebService

public interface MyService

{

@WebMethod(operationName = "doSomething")

Future<?> doSomething(

@WebParam(name = "someParam") String someParam,
AsyncHandler<DoSomethingResult> asyncHandler);

}
But with this I just god the error : "Could not find wsdl:binding operation
info for web method doSomething"

So I guess this means I would have to annotate some binding information? or
is this impossible to do with annotations?
Post by Kent Närling
Hi!
We declare our SOAP interfaces in java and then build the WSDL:s from the
java code since 99% of our clients are in java and to make it most
convenient for them we have decided to follow this path.
@WebService
public interface MyService
{
@WebMethod(operationName = "doSomething")
DoSomethingResult doSomething(
@WebParam(name = "someParam") String someParam);
}
Now, we could like to be able to call this using the async way with
callbacks, is there some way we can declare this manually with annotations?
(ie without generating the code from wsdl)
And would it then be possible to JUST declare the callback variations,
since we know we won't use the polling approach etc?
Thanks
/Kent
Daniel Kulp
2011-08-17 16:08:40 UTC
Permalink
Post by Kent Närling
@WebService
public interface MyService
{
@WebMethod(operationName = "doSomething")
Future<?> doSomething(
@WebParam(name = "someParam") String someParam,
AsyncHandler<DoSomethingResult> asyncHandler);
}
But with this I just god the error : "Could not find wsdl:binding operation
info for web method doSomething"
So I guess this means I would have to annotate some binding information? or
is this impossible to do with annotations?
You ALWAYS have to have the non-async versions there. Thus, put your
original method signature in there. You can then optionally add the async
versions as needed and only for the methods you need.

Dan
Post by Kent Närling
Post by Kent Närling
Hi!
We declare our SOAP interfaces in java and then build the WSDL:s from the
java code since 99% of our clients are in java and to make it most
convenient for them we have decided to follow this path.
@WebService
public interface MyService
{
@WebMethod(operationName = "doSomething")
DoSomethingResult doSomething(
@WebParam(name = "someParam") String someParam);
}
Now, we could like to be able to call this using the async way with
callbacks, is there some way we can declare this manually with
annotations? (ie without generating the code from wsdl)
And would it then be possible to JUST declare the callback variations,
since we know we won't use the polling approach etc?
Thanks
/Kent
--
Daniel Kulp
dkulp-1oDqGaOF3Lkdnm+***@public.gmane.org
http://dankulp.com/blog
Talend - http://www.talend.com
Kent Närling
2011-08-17 22:48:30 UTC
Permalink
Post by Kent Närling
Post by Kent Närling
@WebService
public interface MyService
{
@WebMethod(operationName = "doSomething")
Future<?> doSomething(
@WebParam(name = "someParam") String someParam,
AsyncHandler<DoSomethingResult> asyncHandler);
}
But with this I just god the error : "Could not find wsdl:binding
operation
Post by Kent Närling
info for web method doSomething"
So I guess this means I would have to annotate some binding information?
or
Post by Kent Närling
is this impossible to do with annotations?
You ALWAYS have to have the non-async versions there. Thus, put your
original method signature in there. You can then optionally add the async
versions as needed and only for the methods you need.
Dan
Does this mean that the server side will have to implement the async
version as well?
(would be a bit odd if the server has to implement the same method twice?
Since it has to implement the same interface then it has to implement the
async version...
Also, can the method name & SOAP operation name be the same? or should the
methods have different names?
@WebService
public interface MyService
{
@WebMethod(operationName = "doSomething")
DoSomethingResult doSomething(
@WebParam(name = "someParam") String someParam);
@WebMethod(operationName = "doSomething")
Future<?> doSomething(
@WebParam(name = "someParam") String someParam,
AsyncHandler<DoSomethingResult> handler);
}
Or?
I tried to declare it as above, still get the same error as before:
"Could not find wsdl:binding operation info for web method doSomething"

Do I have to
Kent Närling
2011-08-26 07:25:35 UTC
Permalink
Now I did some small modifcations to my interfaces so I created a sample
service with a method declared like:
@WebMethod(operationName = "doAdd")
String doAdd(
@WebParam(name = "a") String a,
@WebParam(name = "b") String b);

@WebMethod(operationName = "doAdd")
@WebEndpoint(name="doAdd")
Future<?> doAddAsync(
String a,
String b,
AsyncHandler<String> handler);


The server implements this (with an empty stub for the async call) and
publishes simply with:

AdderService service = new AdderService();
Endpoint.publish("http://localhost:8989/adder", service);

The client simply creates the interface connection with:
AdderInterface adder;

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(AdderInterface.class);
factory.setAddress("http://localhost:8989/adder");
adder = (AdderInterface)factory.create();

Now, STILL, if I call the async method I get:
"javax.xml.ws.WebServiceException: Could not find wsdl:binding operation
info for web method doAddAsync."

It seems to me that CXF thinks that the operation name on the server is
"doAddAsync" despite that I explictly named it as "doAdd" in the annotation?

There should be a way to tell CXF through annotations that "for this method
stub X, call SOAP method Y on the server"?
Or am I missunderstanding what the problem is here?

I have a full sample code of the above if anyone is interested I can send
it, I cannot get this to work and I am a bit stuck right now... :-(
Post by Kent Närling
Post by Kent Närling
Post by Kent Närling
@WebService
public interface MyService
{
@WebMethod(operationName = "doSomething")
Future<?> doSomething(
@WebParam(name = "someParam") String someParam,
AsyncHandler<DoSomethingResult> asyncHandler);
}
But with this I just god the error : "Could not find wsdl:binding
operation
Post by Kent Närling
info for web method doSomething"
So I guess this means I would have to annotate some binding
information? or
Post by Kent Närling
is this impossible to do with annotations?
You ALWAYS have to have the non-async versions there. Thus, put your
original method signature in there. You can then optionally add the async
versions as needed and only for the methods you need.
Dan
Does this mean that the server side will have to implement the async
version as well?
(would be a bit odd if the server has to implement the same method twice?
Since it has to implement the same interface then it has to implement the
async version...
Also, can the method name & SOAP operation name be the same? or should the
methods have different names?
@WebService
public interface MyService
{
@WebMethod(operationName = "doSomething")
DoSomethingResult doSomething(
@WebParam(name = "someParam") String someParam);
@WebMethod(operationName = "doSomething")
Future<?> doSomething(
@WebParam(name = "someParam") String someParam,
AsyncHandler<DoSomethingResult> handler);
}
Or?
"Could not find wsdl:binding operation info for web method doSomething"
Do I have to
Daniel Kulp
2011-08-26 15:15:31 UTC
Permalink
Creating the async methods can be tricky as the request object gets unwrapped,
the the wrapper object is used for the callback.

My suggestion is to create your service, grab the wsdl, and generate a client
with it enabling the async methods. (with 2.4.2, you can pass -asyncMethods
flag). Use that generated interface as the basis fro your async methods and
such.

Dan
Post by Kent Närling
Now I did some small modifcations to my interfaces so I created a sample
@WebMethod(operationName = "doAdd")
String doAdd(
@WebParam(name = "a") String a,
@WebParam(name = "b") String b);
@WebMethod(operationName = "doAdd")
@WebEndpoint(name="doAdd")
Future<?> doAddAsync(
String a,
String b,
AsyncHandler<String> handler);
The server implements this (with an empty stub for the async call) and
AdderService service = new AdderService();
Endpoint.publish("http://localhost:8989/adder", service);
AdderInterface adder;
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(AdderInterface.class);
factory.setAddress("http://localhost:8989/adder");
adder = (AdderInterface)factory.create();
"javax.xml.ws.WebServiceException: Could not find wsdl:binding operation
info for web method doAddAsync."
It seems to me that CXF thinks that the operation name on the server is
"doAddAsync" despite that I explictly named it as "doAdd" in the annotation?
There should be a way to tell CXF through annotations that "for this method
stub X, call SOAP method Y on the server"?
Or am I missunderstanding what the problem is here?
I have a full sample code of the above if anyone is interested I can send
it, I cannot get this to work and I am a bit stuck right now... :-(
Post by Kent Närling
Post by Kent Närling
Post by Kent Närling
@WebService
public interface MyService
{
@WebMethod(operationName = "doSomething")
Future<?> doSomething(
@WebParam(name = "someParam") String someParam,
AsyncHandler<DoSomethingResult> asyncHandler);
}
But with this I just god the error : "Could not find
wsdl:binding
operation
Post by Kent Närling
info for web method doSomething"
So I guess this means I would have to annotate some binding
information? or
Post by Kent Närling
is this impossible to do with annotations?
You ALWAYS have to have the non-async versions there. Thus, put your
original method signature in there. You can then optionally add
the
async
versions as needed and only for the methods you need.
Dan
Does this mean that the server side will have to implement the async
version as well?
(would be a bit odd if the server has to implement the same method twice?
Since it has to implement the same interface then it has to implement
the async version...
Also, can the method name & SOAP operation name be the same? or should
the methods have different names?
@WebService
public interface MyService
{
@WebMethod(operationName = "doSomething")
DoSomethingResult doSomething(
@WebParam(name = "someParam") String someParam);
@WebMethod(operationName = "doSomething")
Future<?> doSomething(
@WebParam(name = "someParam") String someParam,
AsyncHandler<DoSomethingResult> handler);
}
Or?
"Could not find wsdl:binding operation info for web method doSomething"
Do I have to
--
Daniel Kulp
dkulp-1oDqGaOF3Lkdnm+***@public.gmane.org
http://dankulp.com/blog
Talend - http://www.talend.com
Kent Närling
2011-08-26 16:05:37 UTC
Permalink
Ok, I was considering that but all the samples I saw then depended on the
WSDL:s which we dont want.


But it seems you are saying that once I generated the wsdl:s and then
back-generated the code (to get it correct) I should be able to discard the
wsdl:s if we want and depend only on the code declarations?

Will try this and see how it goes and maybe decrypt the async "magic" a bit
;-)

Thanks!
Post by Daniel Kulp
Creating the async methods can be tricky as the request object gets unwrapped,
the the wrapper object is used for the callback.
My suggestion is to create your service, grab the wsdl, and generate a client
with it enabling the async methods. (with 2.4.2, you can pass
-asyncMethods
flag). Use that generated interface as the basis fro your async methods and
such.
Dan
Post by Kent Närling
Now I did some small modifcations to my interfaces so I created a sample
@WebMethod(operationName = "doAdd")
String doAdd(
@WebParam(name = "a") String a,
@WebParam(name = "b") String b);
@WebMethod(operationName = "doAdd")
@WebEndpoint(name="doAdd")
Future<?> doAddAsync(
String a,
String b,
AsyncHandler<String> handler);
The server implements this (with an empty stub for the async call) and
AdderService service = new AdderService();
Endpoint.publish("http://localhost:8989/adder", service);
AdderInterface adder;
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(AdderInterface.class);
factory.setAddress("http://localhost:8989/adder");
adder = (AdderInterface)factory.create();
"javax.xml.ws.WebServiceException: Could not find wsdl:binding operation
info for web method doAddAsync."
It seems to me that CXF thinks that the operation name on the server is
"doAddAsync" despite that I explictly named it as "doAdd" in the
annotation?
Post by Kent Närling
There should be a way to tell CXF through annotations that "for this
method
Post by Kent Närling
stub X, call SOAP method Y on the server"?
Or am I missunderstanding what the problem is here?
I have a full sample code of the above if anyone is interested I can send
it, I cannot get this to work and I am a bit stuck right now... :-(
Post by Kent Närling
Post by Kent Närling
Post by Kent Närling
@WebService
public interface MyService
{
@WebMethod(operationName = "doSomething")
Future<?> doSomething(
@WebParam(name = "someParam") String someParam,
AsyncHandler<DoSomethingResult> asyncHandler);
}
But with this I just god the error : "Could not find
wsdl:binding
operation
Post by Kent Närling
info for web method doSomething"
So I guess this means I would have to annotate some binding
information? or
Post by Kent Närling
is this impossible to do with annotations?
You ALWAYS have to have the non-async versions there. Thus, put your
original method signature in there. You can then optionally add
the
async
versions as needed and only for the methods you need.
Dan
Does this mean that the server side will have to implement the async
version as well?
(would be a bit odd if the server has to implement the same method twice?
Since it has to implement the same interface then it has to implement
the async version...
Also, can the method name & SOAP operation name be the same? or should
the methods have different names?
@WebService
public interface MyService
{
@WebMethod(operationName = "doSomething")
DoSomethingResult doSomething(
@WebParam(name = "someParam") String someParam);
@WebMethod(operationName = "doSomething")
Future<?> doSomething(
@WebParam(name = "someParam") String someParam,
AsyncHandler<DoSomethingResult> handler);
}
Or?
"Could not find wsdl:binding operation info for web method doSomething"
Do I have to
--
Daniel Kulp
http://dankulp.com/blog
Talend - http://www.talend.com
Loading...