basic authentication in axis wsdl2java generated client code

Discussion in 'Java' started by bill turner, Mar 6, 2008.

  1. bill turner

    bill turner Guest

    I am writing my first webservice client. I ran wsdl2java to generate
    the client code and have been following the documentation provided at
    the axis website. However, my service requires that I do basic
    authentication. This seems like it should be simple enough, but I
    cannot seem to figure it out. The Service class doesn't seem to
    provide what I need, at least that I can see. Nor do there seem to be
    obvious methods on the port object returned from the service object.
    Reading through the API docs hasn't helped and my google searches
    haven't really provided any clues (the results of the searches seem to
    return irrelevant results). Any help would be appreciated! My code is
    below.

    public class Tester {

    public static void main(String[] args) {
    // Make a service
    Z_YXG_SIMPLE_INPUT_TEST_WSServiceLocator service = new
    Z_YXG_SIMPLE_INPUT_TEST_WSServiceLocator();
    System.out.println("service.getServiceName()=" +
    service.getServiceName().toString());

    try {
    // Now use the service to get a stub which implements the SDI
    (Service Definition Interface).
    Z_YXG_SIMPLE_INPUT_TEST_WS port =
    service.getZ_YXG_SIMPLE_INPUT_TEST_WSSoapBinding();

    TABLE_OF_BAPIRET2Holder bapiRet2TableHolder = new
    TABLE_OF_BAPIRET2Holder();
    Integer IN_NO_ROW = new Integer(4);
    String IN_TEXT = "my test";

    // Make the actual call
    port.z_YXG_SIMPLE_INPUT_TEST(bapiRet2TableHolder, IN_NO_ROW,
    IN_TEXT);

    // Do some actual work here...
    } catch (RemoteException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (ServiceException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

    }
    }

    What obvious thing am I missing?

    Thanks!

    bill
     
    bill turner, Mar 6, 2008
    #1
    1. Advertising

  2. bill turner

    bill turner Guest

    On Mar 6, 10:53 am, bill turner <> wrote:
    > I am writing my first webservice client. I ran wsdl2java to generate
    > the client code and have been following the documentation provided at
    > the axis website. However, my service requires that I do basic
    > authentication. This seems like it should be simple enough, but I
    > cannot seem to figure it out. The Service class doesn't seem to
    > provide what I need, at least that I can see. Nor do there seem to be
    > obvious methods on the port object returned from the service object.
    > Reading through the API docs hasn't helped and my google searches
    > haven't really provided any clues (the results of the searches seem to
    > return irrelevant results). Any help would be appreciated! My code is
    > below.
    >
    > public class Tester {
    >
    >         public static void main(String[] args) {
    >             // Make a service
    >                 Z_YXG_SIMPLE_INPUT_TEST_WSServiceLocator service = new
    > Z_YXG_SIMPLE_INPUT_TEST_WSServiceLocator();
    >                 System.out.println("service.getServiceName()=" +
    > service.getServiceName().toString());
    >
    >             try {
    >                     // Now use the service to get a stub which implements the SDI
    > (Service Definition Interface).
    >                         Z_YXG_SIMPLE_INPUT_TEST_WS port =
    > service.getZ_YXG_SIMPLE_INPUT_TEST_WSSoapBinding();
    >
    >                         TABLE_OF_BAPIRET2Holder bapiRet2TableHolder = new
    > TABLE_OF_BAPIRET2Holder();
    >                     Integer IN_NO_ROW = new Integer(4);
    >                     String IN_TEXT = "my test";
    >
    >                     // Make the actual call
    >                         port.z_YXG_SIMPLE_INPUT_TEST(bapiRet2TableHolder, IN_NO_ROW,
    > IN_TEXT);
    >
    >                         // Do some actual work here...
    >                 } catch (RemoteException e) {
    >                         // TODO Auto-generated catch block
    >                         e.printStackTrace();
    >                 } catch (ServiceException e) {
    >                         // TODO Auto-generated catch block
    >                         e.printStackTrace();
    >                 }
    >
    >         }
    >
    > }
    >
    > What obvious thing am I missing?
    >
    > Thanks!
    >
    > bill


    Never mind. I figured it out. After getting the handle to my port, I
    needed to cast my port object to Stub and then call the appropriate
    methods, as below.

    ((Stub) port).setUsername("myUserId");
    ((Stub) port).setPassword("myPassword");

    Thanks to anyone who looked at this!

    bill
     
    bill turner, Mar 6, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sandy Dunlop

    Problem with Apache AXIS WSDL2Java

    Sandy Dunlop, Oct 4, 2003, in forum: Java
    Replies:
    1
    Views:
    962
    Sandy Dunlop
    Oct 4, 2003
  2. Replies:
    0
    Views:
    953
  3. dukehoops
    Replies:
    0
    Views:
    1,247
    dukehoops
    Jun 27, 2005
  4. Replies:
    0
    Views:
    918
  5. Replies:
    0
    Views:
    796
Loading...

Share This Page