And to give you yet a third option.... :-)
URL wsdlURL = MyService.class.getClassLoader
.getResource ("myService.wsdl");
QName serviceName = new QName("urn:myService", "MyService");
MyService service = new MyService(wsdlURL, serviceName);
ServicePort client = service.getServicePort();
BindingProvider provider = (BindingProvider)client;
provider.getRequestContext().put(
BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"https://my/new/url/to/the/service");
Again, completely JAX-WS compliant code.
Enjoy!
Dan
On Thursday 30 August 2007, Joe Sunday wrote:
> Sorry if this one is easy, but I can't seem to find it...
>
> I've got an interface I generated from a local wsdl, and the wsdl
> files are both available on my classpath:
> <definitions targetNamespace="urn:myService"
> xmlns="http://schemas.xmlsoap.org/wsdl/"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:interface="urn:service2">
> <import location="service2.wsdl" namespace="urn:service2" />
> <service name="MyService">
> <port binding="interface:ServiceBinding" name="ServicePort">
> <soap:address location="https://localhost/sdk/myService" />
>
> How do I create a client for this wsdl against a random url? The
> binding classes seem to only accept the urn and address specified in
> the wsdl, which doesn't work if the url I actually want to talk to
> isn't localhost/sdk/myService
>
> URL wsdlURL = MyService.class.getClassLoader.getResource
> ("myService.wsdl");
> QName serviceName = new QName("urn:myService", "MyService");
> MyService service = new MyService(wsdlURL, serviceName);
> ServicePort client = service.getServicePort();
>
> I don't see a generated ServiceLocator in the classes wsdl2java
> generated anywhere.
>
> --Joe
--
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727 C: 508-380-7194
[EMAIL PROTECTED]
http://www.dankulp.com/blog