cancel
Showing results for 
Search instead for 
Did you mean: 

Error HTTP 401 on SAP Web services

Former Member
0 Kudos

Hello,

I'm creating a web service client from a wsdl file. The web service client is created correctly.

If I access the wsdl url by browser, it ask me username and password, and it works fine.

But when I test the web service, I have an "HTTP 401 - Unauthorized" error.

How can I solve the problem?

Bye

Paolo

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Paolo,

How are you doing your tests & how did you configure your logical port (authentication) for the this consumer proxy?

Regards, Trevor

Former Member
0 Kudos

Hi Trevor,

thanks for your reply. I' use netbeans to develop and test my application.

I didn't configure any proxy or port on my client. Do you thinks it is a proxy problem?

I think I have to manage the basic authentication on my web service client, maybe using the BindingProvider class.

Is it?

Bye Paolo

Former Member
0 Kudos

Hi Paolo,

Sorry, I thought you were doing the Client Proxy on SAP Abap...But the concept is kinda similar with the requirement for logical port binding when developing client proxies on both.

I haven't worked with client proxies on Netbeans but it could be one of 2 problems:

- It might be because you're behind an HTTP firewall proxy then refer to

[http://ui.netbeans.org/docs/ui/proxyConfiguration/] or

- It might be be some additional work to configure web service client for basic authentication on NetBeans, then refer to:

[http://netbeans.org/kb/docs/websvc/wsit.html] (specifically the section on "Getting to Know the Secured Calculator Sample")

Regards, Trevor

Former Member
0 Kudos

Hi Trevor,

I have solved my problem.

I have used the Authenticator class to manage the basic authentication. I post the code listing:

import java.util.Map;

import javax.xml.ws.BindingProvider;

import javax.xml.ws.Holder;

import java.net.*;

import java.lang.*;

import java.util.*;

public class WebServiceClient {

static class MyAuthenticator extends Authenticator {

public PasswordAuthentication getPasswordAuthentication() {

return (new PasswordAuthentication("username", "password".toCharArray()));

}

}

/**

  • @param args the command line arguments

*/

public static void main(String[] args) {

try { // Call Web Service Operation

Authenticator.setDefault(new MyAuthenticator());

// web service execution

...........

} catch (Exception ex) {

// TODO handle custom exceptions here

System.out.println("Result = "+ex);

}

}

}

Thanks for your help.

Ciao Paolo