Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jax-ws client requires WSDL file at runtime ? #87

Open
DoneSpeak opened this issue Apr 10, 2020 · 1 comment
Open

Jax-ws client requires WSDL file at runtime ? #87

DoneSpeak opened this issue Apr 10, 2020 · 1 comment
Labels

Comments

@DoneSpeak
Copy link

Has the following problem been solved which I copy from Jax-ws client requires WSDL file at runtime ? and bothering me a lot.


I generated client and server code for my wsdl using wsimport.

However the client code on startup is looking for the WSDL file in the location it existed in on the machine where I ran wsimport. I would imagine that with all the annotations in the generated code the client should not require the .wsdl at runtime ?

The problem is, when I take the standalone client code and distribute it to other machines, the client fails with the "Failed to access WSDL file exception".

Exception in thread "AWT-EventQueue-0" javax.xml.ws.WebServiceException: Failed to access the WSDL at: file:/C:/BackendManagerForGUI.wsdl. It failed with:
/C:/BackendManagerForGUI.wsdl (No such file or directory).
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:162)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:144)
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:254)
at com.sun.xml.ws.client.WSServiceDelegate.(WSServiceDelegate.java:217)
at com.sun.xml.ws.client.WSServiceDelegate.(WSServiceDelegate.java:174)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
at javax.xml.ws.Service.(Service.java:56)

I am creating a proxy using code that looks like:

            BackendManagerService bm = new BackendManagerService();
           
            port = bm.getBackendManagerPort();

            // Use Proxy Instance as BindingProvider
            BindingProvider bp = (BindingProvider) port;

            Map<String, Object> rc = bp.getRequestContext();
            rc.put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
            "http://localhost:9077/BackManager");

Is there some other way for me to create the client service so that it does not require the .wsdl file at runtime ?

@andham
Copy link
Member

andham commented Apr 12, 2020

This mojo is just a wrapper around the JAX-WS toolset, so what you're asking about is about the classes generated by that tool (wsimport).
Having said that I solved this by including the wsdl in the jar and make the generated ws client use it during runtime by providing this mojo execution configuration:

    <configuration>
        <packageName>com.acme.foo.wsclient</packageName>
        <wsdlDirectory>${project.basedir}/src/main/resources</wsdlDirectory>
        <wsdlFiles>
            <wsdlFile>com/acme/foo/wsclient/BarService.wsdl</wsdlFile>
        </wsdlFiles>
        <wsdlLocation>BarService.wsdl</wsdlLocation>
        <xuseBaseResourceAndURLToLoadWSDL>true</xuseBaseResourceAndURLToLoadWSDL>
    </configuration>

The trick here is the combination of xuseBaseResourceAndURLToLoadWSDL and wsdlLocation. Do note that the wsdl file needs to be in the package path of the generated client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants