2

This means i would NOT use SoapUI, or any other Application to test the WSDL.

i am looking at wsdl4j as this is potentially the only one out there, unless i am missing something available in jdk.

Here is what i tried:

class : WSDLtestvip.java

import java.net.HttpURLConnection;
import java.net.URL;

public class WSDLtestvip {



    public boolean isWSDLAvailable(String wsdlAddr) {
        HttpURLConnection c = null;
        try {
            URL u = new URL(wsdlAddr);
            c = (HttpURLConnection) u.openConnection();
            c.setRequestMethod("HEAD");
            c.getInputStream();
            return c.getResponseCode() == 200;
        } catch (Exception e) {
            return false;
        } finally {
            if (c != null)
                c.disconnect();
        }

    }
}

class: WsdlTester.java

public class WsdlTester {

    public static void main(String[] args) {

        WSDLtestvip wstvip = new WSDLtestvip();
        boolean result = wstvip
                .isWSDLAvailable("https://a.b.c/aaa?wsdl");

        System.out.println(result);

    }

}

and it gives me false ALL the time How can i use the same for https

acdcjunior
  • 132,397
  • 37
  • 331
  • 304
kamal
  • 9,637
  • 30
  • 101
  • 168

1 Answers1

4

Suggestion:

    private boolean isWSDLAvailable(String wsdlAddr) {
            HttpURLConnection c = null;
            try {
                URL u = new URL(wsdlAddr);
                c = (HttpURLConnection) u.openConnection();
                c.setRequestMethod("HEAD");
                c.getInputStream();
                return c.getResponseCode() == 200;
            } catch (Exception e) {
                return false;
            } finally {
                if (c != null) c.disconnect();
            }    
    }

And you can check content-type too, if needed.

Jonathan Simon Prates
  • 1,122
  • 2
  • 12
  • 28