Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package linwebservicetest;
- import java.net.Authenticator;
- public class Main {
- public static void main(String[] args) {
- String userName = "cramo";
- String password = "INSERTPASSHERE";
- Authenticator.setDefault(new BasicHTTPAuthenticator(userName, password));
- try { // Call Web Service Operation
- https.invoice_lindorff_com.webservices.LinaxInvoiceWebService service = new https.invoice_lindorff_com.webservices.LinaxInvoiceWebService();
- https.invoice_lindorff_com.webservices.ILindorffInvoiceWebService port = service.getWS2007HttpBindingILindorffInvoiceWebService();
- // TODO initialize WS operation arguments here
- java.lang.String customerNumber = "1";
- // TODO process result here
- org.datacontract.schemas._2004._07.lindorff_invoice_web_service_interfaces.Customer result = port.getCustomer(customerNumber);
- System.out.println("Result = "+result);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- }
- package linwebservicetest;
- import java.net.Authenticator;
- import java.net.PasswordAuthentication;
- import java.util.logging.Logger;
- /**
- *
- * @author developer
- */
- public class BasicHTTPAuthenticator extends Authenticator {
- private String userName;
- private String password;
- Logger log = Logger.getLogger(BasicHTTPAuthenticator.class.getName());
- public BasicHTTPAuthenticator(String userName, String password) {
- this.userName = userName;
- this.password = password;
- }
- @Override
- protected PasswordAuthentication getPasswordAuthentication() {
- log.fine("getPasswordAuthenticator, protocol is " + this.getRequestingProtocol()
- + " userName is " + userName);
- // only return username / password if using https
- // because we don't want to show them in clear text
- if (this.getRequestingProtocol().equalsIgnoreCase("https")) {
- return new PasswordAuthentication(userName,
- password.toCharArray());
- } else {
- return null;
- }
- }
- public String getUserName() {
- return userName;
- }
- public void setUserName(String userName) {
- this.userName = userName;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement