wood burning stoves 2.0*
The moose likes Web Services and the fly likes javax.xml.rpc.ServiceFactory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "javax.xml.rpc.ServiceFactory " Watch "javax.xml.rpc.ServiceFactory " New topic
Author

javax.xml.rpc.ServiceFactory

wai yuan
Greenhorn

Joined: Dec 30, 2005
Posts: 9
In the context of JAX-RPC, javax.xml.rpc.ServiceFactory is used directly as following:

ServiceFactory serviceFactory = ServiceFactory.newInstance();
Service wsService = serviceFactory.createService(wsdlUrl,new QNameaDefNameSpaceURI, aServiceName));

My question is that ServiceFactory is an abstract class and createService is a abstract method, does it need to be implemented somewhere?
I can understand in the Axis context because it uses org.apache.axis.client.ServiceFactory which extends javax.xml.rpc.ServiceFactory and has its implementation of createService().But where is the implementation in JAX-RPC context?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
Hello Wai-

Welcome to JavaRanch.

You're right, the method needs to be implemented somewhere, but that's abstracted away from the user/programmer, as far as JAX-RPC is concerned. The javadocs say "The ServiceFactory implementation class is set using the system property SERVICEFACTORY_PROPERTY.", and any actual client implementation would set that to whatever class extends ServiceFactory. Even if you program to the JAX-RPC API, you're still using the Axis client classes. Or you can use some other client implementation if you prefer. The important point is that you can switch implementations without having to change your source code.


Ping & DNS - my free Android networking tools app
wai yuan
Greenhorn

Joined: Dec 30, 2005
Posts: 9
If I don't setup the SERVICEFACTORY_PROPERTY property and use

ServiceFactory serviceFactory = ServiceFactory.newInstance();

directly. Would I be able to get a default implementation?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
What happens if you do ?

It's like the JAXP property to select the XML parser - you can use it, but if you don't, a reasonable, working, default value is supplied for you.
 
Consider Paul's rocket mass heater.
 
subject: javax.xml.rpc.ServiceFactory