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 is running.
In production i don't want expose the wsdl, and i am trying to modify the client for don't require wsdl, all my intends are wrong, i find this:
WebService_Service svc = new WebService_Service(
null,
new QName("http://www.example.com/ws", "WebService"));
WebService port = svc.getPort(WebService.class);
BindingProvider bindingProvider = (BindingProvider) port;
bindingProvider.getRequestContext()
.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://www.example.com/real_endpoint_url_goes_here");
but when the first line is executed i found this exception:
Message: El contenido no está permitido en el prólogo.
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.wrapException(Unknown Source)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.next(Unknown Source)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.nextContent(Unknown Source)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.nextElementContent(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.hasWSDLDefinitions(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(Unknown Source)
at javax.xml.ws.Service.<init>(Unknown Source)
Any idea to ignore wsdl?
WSDL file documents in a machine readable (XML) format what the methods (and args for methods) offered by a web service. You do not need a WSDL file if you know what the methods and args are - though WSDL is very good to have as a means of making the web service public interface more 'contractified', if you will.
Generate the client code as follows: In the Project Explorer, right-click your client project's WSDL file, and then select WebLogic Web Services > Generate Web Service Client from the drop-down menu, as Figure 1 shows. This will open the New Web Service Client dialog that Figure 2 shows.
WSDL, or Web Service Description Language, is an XML based definition language. It's used for describing the functionality of a SOAP based web service. WSDL files are central to testing SOAP-based services. SoapUI uses WSDL files to generate test requests, assertions and mock services.
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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With