I'm using Netbeans 6.5 to generate the JAX-WS Metro service and Glassfish 2.1 as the application server.
Assume I have two web services e.g.
...
@WebMethod(operationName = "doXXX")
public String doXXX(
@WebParam(name = "id") String id
...
...
@WebMethod(operationName = "doYYY")
public String doYYY(
@WebParam(name = "result") String result
...
and I have a Web Service client (a Java application) tha开发者_运维技巧t happily calls both.
I now want method XXX to call method YYY i.e. I need to place the client proxy for YYY inside of web service XXX.
How do I do this?
You shouldn't attempt to proxy a request to invoke a method inside the same application - this will incur needless serialization/deserialization of Objects to XML messages and back.
If you need to call another method inside the same application, re-design your application so that you can gain access to whatever area of the application you need to invoke.
I played around and figured it out.
You don't want to call the actual web service via a proxy client because then you will needlessly serialize / deserialize the data.
Assume in the example above, that the doXXX method is inside a class called XXX and that the doYYY method is inside a class called YYY.
(Note that the class would be annotated by a @WebService() tag.)
To call doYYY() from the doXXX method:
YYY yyy = new YYY ();
yyy.doYYY ();
精彩评论