views:

434

answers:

1

I used Netbeans to generate Web Sevice client code from WSDL url. But I can't change endpoint address at run time using code.

Please help me to solve that problem!

+2  A: 

You can do it two ways:

1) Cast port to BindingProvider and specify BindingProvider.ENDPOINT_ADDRESS_PROPERTY property

MyService service = new MyService();
MyPort port = service....
BindingProvider bindingProvider = (BindingProvider) port;
bindingProvider.getRequestContext().put(
BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://New.Endpoint/service");

2) You can call the generated service constructor which takes WSDL URL as parameter.

QName qname = new QName("http://serviceuri/", "service");
String wsdl = "http://New.Endpoint/service?wsdl";
MyServiec service = new MyServiec(new URL(wsdl), qname);
MyPort port = check...;
Chandra Patni