简体   繁体   中英

Webservice client cannot find wsdl

I have created two webservices clients in NetBeans 7.1, mimicking the tutorial they have on their website.

I had done the first one a while ago against a wsdl file located at a http location, and had no problem using the webservice

The webservice I am working with at the moment has a wsdl file located at a https location. The setup of the service went off without a hitch. The only difference with the first one was a popup alerting me to a security certificate, which I accepted. Service, Generated Sources, META-INF etc are all created successfully. A local copy of the wsdl file is stored on my pc under the src/.. folder.

However, as soon as I go to run my code, I receive this error:

Cannot find ' https://-domain-.net/-XYZServices-/-ABCXML?wsdl-' wsdl. Place the resource correctly in the classpath.

I found several similar issues in Stackoverflow and other places online, but nothing that really addressed my problem. I tried several suggestions anyway:

I checked the jax-ws-catalog.xml file, and found the url quoted above mapped to the local folder where the local copy of the wsdl is stored. I checked whether that local folder actually contained the wsdl file - it did. I tried editing the url in the jax-ws-catalog.xml file to point to port 8080 and 8081 - no joy.

I guess it is a security issue, but have no clue as to how to fix this.

Can anyone point me in the right direction here.

FYI: I'm fairly new to java and NetBeans.

Thanks.

The best way to avoid the error "Cannot find wsdl. Place the resource correctly in the classpath." is to use wsdllocation to specify the location of the wsdl and also to package the wsdl as part of the jar.

When you specify the wsdllocation make sure you add "/" to the beginning of the location.

wsimport  -keep -Xnocompile  -wsdllocation /schema/10.0/MyService.wsdl  schema/10.0/MyService.wsdl

Not sure if this helps, but...

From Here

On the client side to consume SSL enabled Web service: - in the New Web Service Client wizard under WSDL and Client location specify the WSDL file of the Web Service by setting WSDL URL in form of https://:8181// - then right click on the created web service and choose Edit Web Service Attributes and under Wsimport Options correct the wsdlLocation option to the following form: /META-INF/wsdl/_8181//.wsdl

Whenever you refresh the web service a fresh wsdl file gets loaded from the deployed application and the wsdl file gets loaded as a resource defined by the correct path (mentioned wsdlLocation option value).

Just put your WSDL file in your classpath, etc., src/main/resources/MyWsdl.xml and use this to get it:

URL url = new URL(baseUrl, "classpath:MyWsdl.xml");

Also do not forget to add this on your service class that extends javax.xml.ws.Service:

@WebServiceClient(name = "MyService", targetNamespace = "http://example.org/", wsdlLocation = "classpath:MyWsdl.xml")

Make sure that you have configured your web service. One way to do so is to implement a class that extends javax.ws.rs.core.Application . That is, add a class which is similar to the following:

import java.util.Set;
import javax.ws.rs.core.Application;


@javax.ws.rs.ApplicationPath("rest")
public class ApplicationConfig extends Application {

    @Override
    public Set<Class<?>> getClasses() {
        Set<Class<?>> resources = new java.util.HashSet<Class<?>>();
        addRestResourceClasses(resources);
        return resources;
    }


    private void addRestResourceClasses(Set<Class<?>> resources) {
        resources.add(rest.HelloWorld.class);
        resources.add(rest.Search.class);

        // Here continue adding all the JAX-RS classes that you have
    }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM