0
我已經使用soapUI和apache-cxf-2.7.2創建了https web服務的客戶端代碼。有一個名爲MYService_BasicEndpoint_Client.java包含此方法的類:如何在客戶端設置https Web服務的用戶名和密碼?
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();
}
但是當我運行它的結果是HTTP響應401(未授權),因爲沒有任何選項來設置HTTPS網絡服務的用戶名和密碼。但是我可以在soapUI中運行此服務的測試用例,因爲有一個選項可以爲端點設置用戶名和密碼。我如何在由soapUI和apache-cxf-2.7.2創建的代碼中設置它們?