1

I have created client code of an https web service using soapUI and apache-cxf-2.7.2. There is a class named MYService_BasicEndpoint_Client.java which contains this method:

public static void main(String args[]) throws java.lang.Exception {
URL wsdlURL = MYServiceWcf.WSDL_LOCATION;
if (args.length > 0 && args[0] != null && !"".equals(args[0])) { 
    File wsdlFile = new File(args[0]);
    try {
        if (wsdlFile.exists()) {
            wsdlURL = wsdlFile.toURI().toURL();
        } else {
            wsdlURL = new URL(args[0]);
        }
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
}    MYServiceWcf ss = new MYServiceWcf(wsdlURL, SERVICE_NAME);
IMYService port = ss.getBasicEndpoint();
port.webserviceMethod();
}

But when I run it the result is http response 401 (Unauthorized) because there isn't any option to set username and password of https web service. But I can run test case of this service within soapUI because there is an option to set username and password for endpoint. how can I set them within the code above which created by soapUI and apache-cxf-2.7.2?

4

0 回答 0