This section outlines how to use the XFire proxy classes. This makes it easy to reuse your existing service classes and invoke your service. If you need to invoke someone else's service, check out the Client and Server Stub Generation from WSDL and Dynamic Client sections. If you are using Spring, please check out the information relating to clients in Spring Remoting.
First you need to create a Service like you do on your server. This provides the metadata about how the service is structured:
Next, you'll need to create a proxy for your service:
And its as simple as that! Please note that YourService should be an interface and not a class that implements that interface.
Using non-default configurations
If you have a services.xml that specificies non-default fields you may need to supply those to the ObjectServiceFactory. For instance take this service definition:
This would translate into:
Or to take another example. Say you are using JSR 181 annotations:
Or try mixing annotations with JSR 181:
Using Proxies with the local transport
One additional step is needed if you're using XFire's local transport. You need to pass in the XFire instance you're using so the server and the client both have access to the same LocalTransport.
Often you'll want to do this in unit tests. If you are extending one of XFire's unit tests you can arrang it like so:
HTTP with basic authentication but without JSR-181
If you're using XFire with HTTP and you use basic authentication, the following snippet of code will allow you to access a SOAP service as a client (for example in a unit test).
You should now be able to invoke methods on 'soapTest'.
Be sure to
otherwise Proxy.getInvocationHandler won't work.
HTTP with basic authentication and JSR-181
If you're using XFire with HTTP and you use basic authentication, the following snippet of code will allow you to access a SOAP service as a client (for example in a unit test). This piece of code uses JSR-181 style annotations.
You should now be able to invoke methods on 'soapTest'.
Configuring HTTP client properties
You can modify behaviour of HTTP client by specifying your own HttpClientParams object:
Some properties of Http client , for easier use, are accesible as Client properties :
Note: for other properties of Client object check Transports section of User Guide


