Re: Axis Client and Authentication
"Raymond Hooker (rhooker)" <[email protected]>
| Newsgroups | gmane.org.user-groups.trijug.juglist |
|---|---|
| Message-ID | <848DB51F3E58E146B08D188F803DCB6F0752FE67@xmb-rtp-20c.amer.cisco.com> |
Actually I found the problem.. The code below works, but I had an incorrect password. Ray -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Robert Dale Sent: Tuesday, September 02, 2008 4:34 PM To: Triangle Java Users Subject: Re: [Juglist] Axis Client and Authentication This sounds like HTTP basic authentication. You can do it in a portable way... AppService service = new AppService(); AppPort port = service.getAppPort(); // set username and password for http basic auth Map<String, Object> context = ((BindingProvider) port).getRequestContext(); context.put(BindingProvider.USERNAME_PROPERTY, "username"); context.put(BindingProvider.PASSWORD_PROPERTY, "password"); // the rest of your code... port.appMethod(); -- Robert Dale On Tue, Sep 2, 2008 at 3:37 PM, Raymond Hooker (rhooker) <[email protected]> wrote: > I found a possible approach: > java.net.URL url = new > java.net.URL("http://localhost:8080"); > ServiceLocator locator = new > ServiceLocator(); > mtaasoap.ServicePortType service = > locator.getService(url); > org.apache.axis.client.Stub stub = > (org.apache.axis.client.Stub) service; > stub.setUsername("user"); > stub.setPassword("password"); > StationStatus ret = service.getStatus(); > System.out.println ("Status > is:"+ret.toString()); I am getting a 401 unauthorized which could > either be because I did not set the username/ password options > properly or because I have the wrong userid/ password. I am trying to > read the C code for the server to check on the password, but any > comments about the above technique would be appreciated. > > Ray > > > > -----Original Message----- > From: [email protected] [mailto:[email protected]] > On Behalf Of Robert Dale > Sent: Tuesday, September 02, 2008 1:13 PM > To: Triangle Java Users > Subject: Re: [Juglist] Axis Client and Authentication > > What's the authentication method, how are you authenticating? > > -- > Robert Dale > > On Tue, Sep 2, 2008 at 10:23 AM, Raymond Hooker (rhooker) > <[email protected]> wrote: >> I am using the Axis WSDL2Java in Eclipse 3.3 and the Web Standard >> Toolkit 2.01 to generate the client from the WSDL. >> >> Ray >> >> -----Original Message----- >> From: Raymond Hooker (rhooker) >> Sent: Tuesday, September 02, 2008 10:20 AM >> To: Triangle Java Users >> Cc: 'Shawn Hartsock' >> Subject: Axis Client and Authentication >> >> I am trying to call a webservice from Grails. Unfortunately it is an >> internal app that does not expose the WSDL (e.g., ..?WSDL) so I can't >> use GroovyWS. I wanted to use Axis2 (which is better supported and >> has more examples) but the service is using RPC encoded. So I am >> down > >> to Axis WSDL2Java. >> >> I can easily generate the client, but I need to pass userid/ password >> for simple authentication. Not only are the examples fairly sparse >> for Axis but none of them set a userid and password. For example, >> here > >> is an example from the Axis user's guide: >> file:///C:/axis-1_4/docs/user-guide.html#soapmon >> public class Tester >> { >> public static void main(String [] args) throws Exception { >> // Make a service >> AddressBookService service = new AddressBookServiceLocator(); >> >> // Now use the service to get a stub which implements the SDI. >> AddressBook port = service.getAddressBook(); >> >> // Make the actual call >> Address address = new Address(...); >> port.addEntry("Russell Butek", address); >> }} >> >> Any suggestions or simple examples of calling the generated client. >> >> Ray >> >> _______________________________________________ >> Juglist mailing list >> [email protected] >> http://trijug.org/mailman/listinfo/juglist_trijug.org >> > > _______________________________________________ > Juglist mailing list > [email protected] > http://trijug.org/mailman/listinfo/juglist_trijug.org > -- Robert Dale _______________________________________________ Juglist mailing list [email protected] http://trijug.org/mailman/listinfo/juglist_trijug.org