JAX-WS Loading WSDL from jar

前端 未结 13 952
予麋鹿
予麋鹿 2020-11-28 04:40

I\'m writing a fat client that makes use of a SOAP service for some features (bug reporting etc.)

I\'ve got JAX-WS working fine, but by default (in netbeans at least

13条回答
  •  暖寄归人
    2020-11-28 05:38

    Here's my hack-y workaround.

    I unpack the WSDL from the jar and write it to a file near the jar:

    File wsdl = new File("../lib/service.wsdl");
    InputStream source = getClass().getResource("resources/service.wsdl").openStream();
    FileOutputStream out = new FileOutputStream(wsdl);
    
    byte[] buffer = new byte[512];
    int read;
    while((read = source.read(buffer)) >= 0) {
        out.write(buffer, 0, read);
    }
    

    Then point the service classes to file:../lib/service.wsdl.

    This works, but I'd appreciate if anyone can show me a more elegant solution.

提交回复
热议问题