For a service called MyService, i.e. your WSDL file contains <wsdl:service
name="MyService">, source code generated by WSDL2Java will contain classes
with these (or similar) names (amongst others):
MyServiceLocator
MyServiceSoap
MyServiceSoapStub
You can then invoke myMethod() against the service using code like:
String strEndpointAddress = ...
MyServiceLocator locator = new MyServiceLocator();
locator.setMyServiceSoapEndpointAddress(strEndpointAddress);
MyServiceSoapStub stub =
(MyServiceSoapStub)locator.getPort(MyServiceSoap.class);
stub.myMethod();
Jeff
----- Original Message -----
From: "John Baker" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, June 23, 2005 7:57 AM
Subject: Dynamic Endpoints
> Hi,
>
> I'm trying to simplify the configuration of a pre-packaged Axis server
which
> already has a bunch of services deployed. I'd like users to be easily be
> able to set the endpoint on services that were generated from wsdl, so I'm
> using the Java stub as my deployed service. You can think of this model as
a
> proxy, in a rather simple sense; it does nothing more than call the same
> service on another server.
>
> I appreciate that it's possible to set an endpoint for a service through a
> deploy.wsdd file. However I would like to do this dynamically and am
> wondering how I would do this? I think I need to set the parameter
> dynamically so everytime an instance of a service is created, an endpoint
is
> set.
>
> I've got something like this:
>
> org.apache.axis.client.Service service =
> org.apache.axis.client.ServiceFactory.getService("MyService");
> Iterator pi = service.getPorts();
> javax.wsdl.Port port;
> while (pi.hasNext())
> {
> port = (javax.wsdl.Port)pi.next();
> port.addExtensibilityElement(new
SOAPAddressImpl("http://localhost:9090/hello"));
> }
>
> But I suspect it would have to be a little more advanced than my simple
> example :)
>
> I'd also need to write my own SOAPImpl:
>
> protected class SOAPAddressImpl implements
javax.wsdl.extensions.soap.SOAPAddress
> {
> private QName elementType;
> private Boolean required;
> private String uri;
>
> public SOAPAddressImpl(String uri)
> { this.uri = uri; }
>
> public void setElementTpe(QName elementType)
> { this.elementType = elementType; }
>
> public QName getElementType()
> { return (elementType); }
>
> public void setRequired(Boolean required)
> { this.required = required; }
>
> public Boolean getRequired()
> { return (required); }
>
> public void setLocationURI(String uri)
> { this.uri = uri; }
>
> public String getLocationURI()
> { return (uri); }
> }
>
> But I'm not sure what the elementType of required flag would require?
Having
> read the Axis source, I don't think they are used by the client.Service
class anyway.
>
> Any thoughts/pointers?
>
> Thanks,
>
>
> John Baker