没有 WSDL 文档文件的 JAX-WS 客户端 [英] JAX-WS client without a WSDL document file
问题描述
我正在使用网络服务 soa,使用 netbeans (jax-ws) 我使用 netbeans 自动生成客户端,并且一切正常,但我看到 wsdl 在客户端运行时总是在下载.
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.
在生产中,我不想暴露 wsdl,我正在尝试修改客户端,因为不需要 wsdl,我所有的意图都是错误的,我发现:
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)
有什么想法可以忽略 wsdl?
Any idea to ignore wsdl?
推荐答案
最后我使用了 CXF 库,并且我实现了使用 Paul Vargas 的答案:
Finally i use the CXF libraries and i achieve use the Paul Vargas answer:
没有 WSDL 文档文件
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);
使用标准的jaw-ws,这个解决方案不起作用,CXF是必要的.
Using standard jaw-ws, this solution don't work, CXF is necessary.
这篇关于没有 WSDL 文档文件的 JAX-WS 客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!