Reputation: 9785
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
Upvotes: 2
Views: 7080
Reputation: 1247
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.
Upvotes: 4