I am consuming a webservice soa, with netbeans (jax-ws) i use netbeans auto generate client, and all run fine, but i see that the wsdl is always downloading while the client
I needed something like this, too.
In my case, I had put a dummy wsdl without endpoint address inside my web app classpath. After that, I set a valid address at runtime, like this:
String WSDL = "/config/ws/Main_default.wsdl";
Main service = new Main(Main.class.getResource(WSDL), new QName(
"http://www.example.com/", "Main"));
MainWS port = service.getMainWSPort();
BindingProvider bindingProvider = (BindingProvider) port;
bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://app.example.com/ws/services/main");
Object result = port.someMethod("some param");
There are several ways, of which I will tell you two:
Save a copy of the WSDL document file and the schemma files to your project.
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
URL wsdlLocation = classloader.getResource("MyHelloService.wsdl");
QName serviceName= new QName("http://test.com/", "MyHelloService");
MyHelloService service = new MyHelloService(wsdlLocation, serviceName);
service.sayHello("Test");
You may combine the WSDL document file with the schema files.
This solution requires the client generated.
QName qname = new QName("http://thenamespace", "FooService");
FooService service = new FooService(null, qname); // null for ignore WSDL
Foo port = service.getFooPort();
BindingProvider bindingProvider = (BindingProvider) port;
bindingProvider.getRequestContext()
.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://foo.com/soap/fooBean");
// Use the service
String result = port.doSomething(param);
Finally i use the CXF libraries and i achieve use the Paul Vargas answer:
Without a WSDL document file
This solution requires the client generated.
QName qname = new QName("http://thenamespace", "FooService");
FooService service = new FooService(null, qname); // null for ignore WSDL
Foo port = service.getFooPort();
BindingProvider bindingProvider = (BindingProvider) port;
bindingProvider.getRequestContext()
.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://foo.com/soap/fooBean");
// Use the service
String result = port.doSomething(param);
Using standard jaw-ws, this solution don't work, CXF is necessary.
This exception happens while there is a parse error in your xml and there is something wrong at the specified row and column. Check your xml