You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
Here is a simple way to access web service clients from Seam.
Here is what the configuration looks like:
<jaxws:client-factory name="sampleServiceClient"
serviceQName="{http://service.jaxws.taylor.net/}SampleService"
serviceEndpointInterface="net.taylor.sample.service.SampleService"
endpointAddress="@sample.service.endpoint@"/>
Here is the injection of the client:
@In private SampleService sampleServiceClient;
Here is the factory code. Note the use of @Unwrap.
@Scope(ScopeType.APPLICATION)
@Install(value = false, precedence = Install.FRAMEWORK)
@AutoCreate
@BypassInterceptors
public class ClientFactory {
private Object client;
private String serviceQName;
private String wsdlLocation;
private Class<?> serviceEndpointInterface;
private String endpointAddress;
// setters/getters
@Create
public void create() throws Exception {
Service service = Service.create(new URL(getWsdlLocation()), QName
.valueOf(getServiceQName()));
client = service.getPort(getServiceEndpointInterface());
Map<String, Object> requestContext = ((BindingProvider) client)
.getRequestContext();
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
getEndpointAddress());
}
@Unwrap
public Object getClient() {
return client;
}
}
Here is the full code: ClientFactory.java
Hello,
Can you describe where the should be go?
Thank you,
Bertrand.
Hi,
could you please address me to the correct namespace (and xsd) involved in the example above?
Bertrand, I am presuming (and I might be completely wrong! :)) that the configuration has to be set in your components.xml file where all your Seam components are declared. Unfortunately I am stuck too... I am googling for some schema that contains a client-factory element, no success so far.
Regards Jean
Yes, the configuration would go in your components.xml file.
The ClientFactory class is an example. You would create the class in your own jar/package and add a package info file to define the namespace. Optionally, you can define a schema as well.
Hi John,
I'd like to use your code, but I don't understand the configuration. What do you mean by ?
Thx Markus
Forgot to ask how do you dynamically substitude or set the endpoint address?
Thx Markus