我正在使用webbevice soa,netbeans(jax-ws)我使用netbeans自动生成客户端,所有运行正常,但我看到wsdl总是在客户端运行时下载.
在生产中我不想暴露wsdl,我试图修改客户端不需要wsdl,所有我的意图都错了,我发现这个:
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");
Run Code Online (Sandbox Code Playgroud)
但是当第一行执行时我发现了这个例外:
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)
Run Code Online (Sandbox Code Playgroud)
有什么想忽略wsdl?
我正在尝试独立的JAX-WS Web服务,服务器和客户端(意思是,不在Java EE容器内运行).显示独立服务器端的好SO帖子就是这个.
对于客户端,我发现以下三种似乎有效的方法(使用wsimport生成客户端存根之后):
public static void main(String[] args) throws Exception {
String serviceURL = "http://localhost:9000/soap?wsdl";
{ // WAY 1
URL url = new URL(serviceURL);
QName qname = new QName("urn:playground:jax-ws", "MyService");
Service service = Service.create(url, qname);
IHello port = service.getPort(IHello.class);
System.out.println(port.sayHello("Long John"));
}
{ // WAY 2
MyService service = new MyService();
IHello port = service.getHelloPort();
((javax.xml.ws.BindingProvider) port).getRequestContext().put(javax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceURL);
System.out.println(port.sayHello("Long John"));
}
{ // WAY 3
URL url = new URL(serviceURL);
QName qname = new QName("urn:playground:jax-ws", …Run Code Online (Sandbox Code Playgroud)